【发布时间】:2016-12-26 20:33:47
【问题描述】:
我想多次使用相同的组件,但使用不同的文本。我该怎么做?
我的代码: jumbotron.component.html:
<div class="jumbotron text-center">
<h1 >{{jumbotronText}}</h1>
</div>
app.component.ts
@Component({
selector: 'my-app',
template: `
<navbar></navbar>
<jumbotron ></jumbotron>
<jumbotron ></jumbotron>
<jumbotron ></jumbotron>
`
,
directives: [NavbarComponent, JumbotronComponent]})
export class AppComponent { }
我试过这样做:
<jumbotron [jumbotronText]="My text to display"></jumbotron>
还有这个:
<jumbotron jumbotronText="My text to display"></jumbotron>
但只有错误。我认为这应该很容易,但我不知道如何解决这个问题。
【问题讨论】:
标签: data-binding angular components