I am app/click-me.component.ts
examples on the documentation website https://angular.io/docs/ts/latest/guide/user-input.html And I can’t connect the app/click-me.component.ts
app/click-me.component.ts
:
import { Component } from '@angular/core'; @Component({ selector: 'click-me', template: ` <button (click)="onClickMe()">Click me!</button> {{clickMessage}}` }) export class ClickMeComponent { clickMessage = ''; onClickMe() { this.clickMessage = 'You are my hero!'; } }
And I connected the <click-me></click-me>
selector to index.html
<click-me></click-me>
However, nothing happened, and in addition the ClickMeComponent
class ClickMeComponent
highlighted as not active, and ide writes that it is unused. Also in main.ts
added import { ClickMeComponent } from './click-me.component';
and this line also glows as not active.
<click-me></click-me>
to theApp
component template and remember to register your component in thedirectives
field - Alexandr