javascript - Why do all components with Component selectors have to be used in an Angular 2 application? -
please aware working tutorial code here, not strictly correct, works. of time.
i have component class decorated follows:
@component({ selector: "click-here", template: ` <button (click) = "onclickthere($event)">click here!</button> {{clickmessage}} ` })
and used this:
<body> <click-here>loading...</click-here> </body>
then added new component class, decorator has:
selector: "type-here"
when run application npm start
, legion of errors in browser, starting with:
the selector "click-here" did not match elements
why every selector have match element? working not feasible; there must way able have multiple component
decorators, different selector
values, , use of them. how achieve that? doing wrong tutorial hasn't included correct version of? must each component
have name or something?
this relevant element instantiate bootstrap(mycomponent)
.
if bootstrap component , doesn't match selector, angular doesn't know should place it. angular uses selector find place insert component dom.
this means can bootstrap 1 component once inside page. there plans support overriding selector when component passed bootstrap()
isn't supported.
see https://github.com/angular/angular/issues/7136
for components used inside mycomponent
doesn't matter. can have many components want , use need.
Comments
Post a Comment