我需要知道如何通过点击按钮来改变这个片段?我尝试使用ngModel,但它的显示错误ngModel不能与离子段结合.然后,我在FormModule中导入app.module.ts,但仍然存在相同的错误。有谁能告诉我如何在点击时更改分段按钮?谢谢
<ion-segment value="javascript">
<ion-segment-button value="python">
<ion-label>Python</ion-label>
</ion-segment-button>
<ion-segment-button value="javascript">
<ion-label>Javascript</ion-label>
</ion-segment-button>
</ion-segment>
<button (click)="next()></button>发布于 2019-11-10 04:39:14
你似乎不正确地使用离子段。您需要将ionChange事件添加到离子段。遵循离子段的离子文档:https://ionicframework.com/docs/api/segment。
下面是一个例子:
文件中的
<ion-segment (ionChange)="segmentChanged($event)" [(ngModel)]="segment">
<ion-segment-button value="first">
<ion-label>First</ion-label>
</ion-segment-button>
<ion-segment-button value="second">
<ion-label>Second</ion-label>
</ion-segment-button>
</ion-segment>在你的打字稿:
export class Example {
segment = "segment value";
constructor(public navCtrl: NavController) {}
segmentChanged(ev: any) {
// Add your logic here
}
}https://stackoverflow.com/questions/58785403
复制相似问题