I don't know how to change the label text dynamically. When I'm clicking on the second tab position, it is triggering onIndexChanged(args)
and printing the console.log("One" +"Test");
in command prompt. But it doesn't change the text.
first.page.html:
<ActionBar title="Dashboard" class="action-bar">
<Label [text]="'times'" textWrap="true"></Label>
</ActionBar>
first.page.ts:
export class FirstPage {
public times = "Ratings";
....
public onIndexChanged(args) {
let tabView = <TabView>args.object;
if(tabView.selectedIndex == 1){
console.log("One" +"Test");
this.times = "Ratings";
}
}
}
html:
<ActionBar title="Dashboard" class="action-bar">
<Label [text]="labelText" textWrap="true"></Label>
</ActionBar>
<StackLayout>
<Button text="click me" (tap)="changeText()"></Button>
</StackLayout>
ts:
export class FirstPage {
labelText: string = "Times";
changeText() {
this.labelText = "Ratings";
}
}
That should do the trick, the button is only there to see the change, you could do the call however you wanted to.
--EDIT--
swap <Label [text]="labelText" textWrap="true"></Label>
with <Label text="{{ labelText }}" textWrap="true"></Label>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.