I'm just staring Angular and have a simple angular component (the glyphicon glyphicon-star you see on the left in stack over flow questions) which i want to display but I can only get a non clickable star .
here is my code: favorite.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'favorite',
template: `
<i
class="glyphicon"
[class.glyphicon-star-empty] ="!isFavorite"
[class.glyphicon-star]="isFavorite"
(click)="onClick()">
</i>
`
})
export class FavoriteComponent {
isFavorite = false;
onclick() {
this.isFavorite = !this.isFavorite;
}
}
In app.component I'm trying to render this 'favorite' component:
import {Component} from 'angular2/core';
import {CoursesComponent} from './courses.component'
import {AuthorsComponent} from './authors.component'
import {FavoriteComponent} from './favorite.component'
@Component({
selector: 'my-app',
template: '<h1>My First Angular 2 App</h1><courses></courses><authors></authors><button class ="btn btn-primary">Submit</button><br><favorite></favorite>',
directives: [CoursesComponent, AuthorsComponent]
})
export class AppComponent { }
How do I render the component in my app.component ?
Full code here : https://github.com/aindriu80/Angular2withTypeScript
The code doesn't load up the component - i only get the favorite favorite

templateUrl: client/favorite.html