Skip to content

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

@chasenlehara

Description

@chasenlehara

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions