我有我的自定義組件:傳遞變量來定製組件
@Component({
selector: 'my-custom-component',
templateUrl: './my-custom-component.html',
styleUrls: ['./my-custom-component.css']
})
export class MyCustomComponent {
constructor() {
console.log('myCustomComponent');
}
}
我可以這樣使用它:
<my-custom-component></my-custom-component>
但我怎麼能傳遞一個變量?例如:
<my-custom-component custom-title="My Title"></my-custom-component>
並在我的組件代碼中使用它?
在組件中使用輸入:https://angular.io/docs/ts/latest/guide/template-syntax.html#!#inputs-outputs –