0
私はAngular2を使いこなしています。Angular2が機能しない(クリックする)機能が変更されない
//home.component.html
<div class="ui container">
<sm-button class="positive" (click)="remove()">Button</sm-button>
</div>
//home.component.ts
import { Component } from "@angular/core";
@Component({
selector: "home",
templateUrl: `client/components/home/home.component.html`
})
export class HomeComponent {
constructor() {}
remove() {
console.log("Hello");
}
}
しかし、その後、私はこのように変更します。:ボタンをクリックすると
//home.component.html
<div class="ui container">
<sm-button class="positive" (click)="load()">Button</sm-button>
</div>
//home.component.ts
import { Component } from "@angular/core";
@Component({
selector: "home",
templateUrl: `client/components/home/home.component.html`
})
export class HomeComponent {
constructor() {}
load() {
console.log("Hello");
}
}
今ロード機能が見つかりません。だから私のコードは、最初にこのように見えると言いますここで何が起こっているのですか?
EDIT:変更コードは
テンプレートを '@ Component'に追加しました –
コンパイルを忘れましたか?それは、前と後の両方のファイルを投稿した場合に役立ちます。 –
はい。テンプレートはボタンをロードし、クリックするとクリック機能が解除されたときに機能します。これは、home.component.tsで行った変更が実際に何もしていないようなものです。なぜそれが起こっているのだろうか?私はlite-serverを実行していますので、変更を自動コンパイルしないでください。あるいは手動でコンパイルする必要がありますか? – awillis