0
對於我們的NativeScript Angular2應用程序,我們需要底部對齊的選項卡。我們正試圖通過SegmentedBar來實現這一點(因爲我瞭解tabviews無法在NativeScript-Angular2應用程序中底部對齊)。我如何在分段的條形標題中實現字體棒圖標?我試着將這個unicode保存在items數組中,然後在html中分配一個令人敬畏的類,但是這不起作用。任何其他的選擇?在NativeScript中使用字體棒圖標SegmentedBar標題
我的代碼如下 - segmentedbar.ts:
import { Component, ChangeDetectionStrategy } from "@angular/core";
import { SegmentedBarItem } from "ui/segmented-bar";
@Component({
moduleId: module.id,
selector: "maintab",
templateUrl: "./maintab.component.html",
changeDetection: ChangeDetectionStrategy.OnPush
})
export class MainTabComponent {
public myItems: Array;
public prop = "Item " + 0;
constructor() {
this.myItems = [];
for (let i = 1; i < 5; i++) {
let tmpSegmentedBar: SegmentedBarItem = <SegmentedBarItem>new SegmentedBarItem();
tmpSegmentedBar.title = "Tab " + i;
this.myItems.push(tmpSegmentedBar);
}
}
這是我segmentedbar.html
<StackLayout>
<StackLayout>
<!-- >> segmentedbar-basic-html -->
<Label [text]="prop" textWrap="true" vertical-align="center" class="h2 p-15 text-center"></Label>
<SegmentedBar class="m-5" #sb [items]="myItems" selectedIndex="0" (selectedIndexChange)="prop='Item '+ sb.selectedIndex"></SegmentedBar><!-- << segmentedbar-basic-html -->
</StackLayout>
</StackLayout>
爲什麼你不只是在HTML模板中包含圖標? '' –