简体   繁体   English

离子段值检查所有

[英]Ion-segment value checks all

Whenever I'm trying to put the value of ion-segment , all of them go on.每当我尝试输入ion-segment的值时,它们都会继续。 See my image below for reference.请参阅下面的图片以供参考。 在此处输入图片说明
HTML 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);
  }

Image of a rating so you can see the data behind it:评级的图像,以便您可以查看其背后的数据: 在此处输入图片说明

As you can see, I use the rating.Checked value to set the value of ion-segment如您所见,我使用 rating.Checked 值来设置ion-segment的值

value of ion-segment and ion-segment-button had to be between parenthesis. value离子段和离子分段按钮必须是括号之间。 So value="score.Score_id" had to be value="{{score.Score_id}}" .所以value="score.Score_id"必须是value="{{score.Score_id}}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM