Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs on a component’s content being used as its view #270

Open
chasenlehara opened this issue Jun 28, 2018 · 0 comments
Open

Add docs on a component’s content being used as its view #270

chasenlehara opened this issue Jun 28, 2018 · 0 comments
Assignees

Comments

@chasenlehara
Copy link
Member

When a component has no view or an empty view defined, it’ll render its content as its view.

Here’s an abbreviated example from the forums: https://forums.donejs.com/t/how-to-limit-event-outcome-to-element-of-origin/919/8

Component.extend({
  tag: "can-el",
  ViewModel: {
    hovMessage: {
        default: "I'm from can-el",
    }
  }
});
Component.extend({
  tag: "can-simple",
  view: "<can-el>{{hovMessage}}</can-el>",
  ViewModel: {
    hovMessage: {
        default: "I'm from can-simple",
    }
  }
});

<can-simple></can-simple> will then render:

<can-simple>
  <can-el>
    I'm from can-el
  </can-el>
</can-simple>

@phillipskevin says this is a feature, so I think this should be documented in the view docs and maybe also mentioned on the main can-component page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants