我聲明瞭一個選擇「應用程序」組件 然後我用它像後續Angular 2 alpha 22,如何通過屬性傳遞值到組件?在我寫這個模板</p> <pre><code><app title="Awesome Title"></app> </code></pre> <p>:</p> <pre><code>The title passed {{ title }} </code></pre> <p>我沒加寫組件註釋:
@Component({
selector: 'app',
properties: {title:'title'} // also tried ['title']
});
但沒有顯示出來,輸出
The title passed
任何幫助?謝謝
如果您需要使用根應用程序(例如,因爲您從靜態HTML傳遞屬性),您仍然可以。但您必須使用ElementRef: https://github.com/angular/angular/issues/1858#issuecomment-137696843 – filiph
屬性的語法已更改爲['title:title'] – vangorra