每当我试图给ion-segment赋值时,它们都在继续。请看下面的图片作为参考。

HTML
<!-- Segment -->
<ion-segment
scrollable
*ngIf="rating.Type === 'radio'"
class="segment"
value=" rating.Checked "
>
<ion-segment-button
(click)="scoreButton(score, rating)"
*ngFor="let score of rating.Scores"
value="score.Score_id"
>
<!-- {{ score.Descriptions[0].Description }} -->
{{ score.Score_id }}
</ion-segment-button>
</ion-segment>scoreButton()
scoreButton(score: any, rating: any) {
// To make sure only 1 score.Selected can be true.
rating.Scores.map((ratingScore) => {
if (score.Score_id == ratingScore.Score_id) {
score.Selected = true;
} else {
ratingScore.Selected = false;
}
});
rating.Checked = score.Score_id;
console.log(score.Descriptions[0].Description, rating);
}评级图像,以便您可以查看其背后的数据:

如您所见,我使用rating.Checked值来设置ion-segment的值
发布于 2021-06-23 22:26:10
离子段和离子段按钮的value必须在括号之间。所以value="score.Score_id"必须是value="{{score.Score_id}}"。
https://stackoverflow.com/questions/68101635
复制相似问题