我正在玩Angular 2和Material Design Lite。但是,許多Material Design Lite組件在放置到Angular 2組件模板中時似乎會斷裂。Material Design Lite工具提示不適用於Angular 2
例如
app.component.ts
@Component({
selector: 'this-app',
templateUrl: 'app/app.component.html'
})
export class AppComponent {
public message : string = "This is my Application" ;
public menuItems : string[] = ["Personnel", "Contacts", "Accounting"];
public appTitle : string = "Gravity HR";
public messages : string[] = ["message 1", "Message 2", "Message 3 ", "Message 4"];
}
app.component.html
<main class="mdl-layout__content">
<div class="page-content">
<h1>{{message}}</h1>
<div id="inbox1" class="fa fa-inbox fa-2x fa-fw mdl-badge mdl-badge--overlap" data-badge="4"></div>
<div for="inbox1" class="mdl-tooltip">You have {{messages.length}} messages</div>
</div>
</main>
此代碼中的工具提示將不顯示。但是,如果我將代碼複製到角度2組件外部,將顯示工具提示。 See Plunker example
另外,我想能夠做的另一件事就是綁定到div一種像這樣的數據徽章屬性:
<div id="inbox1" class=... data-badge={{messages.length}}>
似乎並沒有得以順利 - 我猜是因爲數據徽章不是div標籤的真正屬性?
感謝您的幫助。
我累了添加這些更改普拉克例子,它似乎沒有有所作爲 -
也
見。有什麼想法嗎? – RHarris
通過我的上述改變,它可以在Firefox中使用,但不能在Chrome中使用。也許與Plunker有關,但一般來說這應該是修復。 –
順便說一句,有關如何綁定到數據徽章屬性的任何想法,以便我可以動態更新徽章值? – RHarris