首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >离子段值检查所有

离子段值检查所有
EN

Stack Overflow用户
提问于 2021-06-23 22:16:56
回答 1查看 15关注 0票数 0

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

HTML

代码语言:javascript
复制
 <!-- 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()

代码语言:javascript
复制
  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的值

EN

回答 1

Stack Overflow用户

发布于 2021-06-23 22:26:10

离子段和离子段按钮的value必须在括号之间。所以value="score.Score_id"必须是value="{{score.Score_id}}"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68101635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档