This should be the simplest possible nested components, but when I load this (via systemjs) all that I see in the browser is "Counters", and the <counter></counter>
has been added to the DOM. There is no sign of "Hello Counter" or of any processing of the counter
component.
import angular from 'angular2/angular2';
var AppComponent = angular
.Component({
selector: 'my-app',
template: '<h1>Counters</h1><counter></counter>'
})
.Class({
constructor: function () { }
});
angular
.Component({
selector: 'counter',
template: '<h2>Hello counter</h2>'
})
.Class({
constructor: function () {}
});
angular.bootstrap(AppComponent);
You must specify all directives which are used in your template in directives
property of View
(or Component
). See this plunker. Correct code:
var Counter = angular
.Component({
selector: 'counter',
template: '<h2>Hello counter</h2>'
})
.Class({
constructor: function () {}
});
var AppComponent = angular
.Component({
selector: 'my-app',
directives: [Counter], // <-- Here we are!
template: '<h1>Counters</h1><counter></counter>'
})
.Class({
constructor: function () { }
});
angular.bootstrap(AppComponent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With