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.

  • Look at the initial project on the planker: plnkr.co/edit/7gr7te6iTXP9zq57oytm If you start from this project you need to add <click-me></click-me> to the App component template and remember to register your component in the directives field - Alexandr

1 answer 1

  • Be sure to Component before use to register in directives.
  • Root component must be initialized via Bootstrap

Show how index.html looks like.