2016-06-30 14 views
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:変更コードは

+0

テンプレートを '@ Component'に追加しました –

+0

コンパイルを忘れましたか?それは、前と後の両方のファイルを投稿した場合に役立ちます。 –

+0

はい。テンプレートはボタンをロードし、クリックするとクリック機能が解除されたときに機能します。これは、home.component.tsで行った変更が実際に何もしていないようなものです。なぜそれが起こっているのだろうか?私はlite-serverを実行していますので、変更を自動コンパイルしないでください。あるいは手動でコンパイルする必要がありますか? – awillis

答えて

0

が正しくTSC-W doesntの仕事のように思えるの完全なファイルを含めます。 サーバコンソールを調べ、コマンドを実行したかどうかを確認してください。 また、コンソールキャッシュをクリアしてみてください。 あなたのjavascriptを見て、更新されたかどうかを確認してください。

関連する問題