• <legend id='2C2ld'><style id='2C2ld'><dir id='2C2ld'><q id='2C2ld'></q></dir></style></legend>

    <i id='2C2ld'><tr id='2C2ld'><dt id='2C2ld'><q id='2C2ld'><span id='2C2ld'><b id='2C2ld'><form id='2C2ld'><ins id='2C2ld'></ins><ul id='2C2ld'></ul><sub id='2C2ld'></sub></form><legend id='2C2ld'></legend><bdo id='2C2ld'><pre id='2C2ld'><center id='2C2ld'></center></pre></bdo></b><th id='2C2ld'></th></span></q></dt></tr></i><div id='2C2ld'><tfoot id='2C2ld'></tfoot><dl id='2C2ld'><fieldset id='2C2ld'></fieldset></dl></div>

    <small id='2C2ld'></small><noframes id='2C2ld'>

      <tfoot id='2C2ld'></tfoot>

          <bdo id='2C2ld'></bdo><ul id='2C2ld'></ul>
      1. 如何在离子无线电元件上使用 ngModel?

        时间:2023-09-08

        <legend id='P8zC3'><style id='P8zC3'><dir id='P8zC3'><q id='P8zC3'></q></dir></style></legend>
          <tbody id='P8zC3'></tbody>
        <i id='P8zC3'><tr id='P8zC3'><dt id='P8zC3'><q id='P8zC3'><span id='P8zC3'><b id='P8zC3'><form id='P8zC3'><ins id='P8zC3'></ins><ul id='P8zC3'></ul><sub id='P8zC3'></sub></form><legend id='P8zC3'></legend><bdo id='P8zC3'><pre id='P8zC3'><center id='P8zC3'></center></pre></bdo></b><th id='P8zC3'></th></span></q></dt></tr></i><div id='P8zC3'><tfoot id='P8zC3'></tfoot><dl id='P8zC3'><fieldset id='P8zC3'></fieldset></dl></div>

                • <bdo id='P8zC3'></bdo><ul id='P8zC3'></ul>

                  <small id='P8zC3'></small><noframes id='P8zC3'>

                  <tfoot id='P8zC3'></tfoot>

                  本文介绍了如何在离子无线电元件上使用 ngModel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在 ion-radio 元素上实现 ngModel,但不知何故它不起作用.这是我的代码:

                  I'm trying to implement a ngModel on a ion-radio element but somehow it doesn't work. This is my code:

                  import {
                    Page
                  } from 'ionic-angular';
                  
                  @Page({
                    templateUrl: 'build/pages/settings/settings.html'
                  })
                  
                  export class Settings {
                    constructor() {
                      this.unit = 2;
                    }
                  }

                  <ion-list radio-group>
                    <ion-list-header>
                      Unit
                    </ion-list-header>
                  
                    <ion-item>
                      <ion-label>Metric (kg)</ion-label>
                      <ion-radio value="1" [(ngModel)]="unit"></ion-radio>
                    </ion-item>
                  
                    <ion-item>
                      <ion-label>Imperial (lbs)</ion-label>
                      <ion-radio value="2" [(ngModel)]="unit"></ion-radio>
                    </ion-item>
                  </ion-list>

                  我尝试在离子输入和离子选择上实现它,效果很好.我还尝试将 directives: [FORM_DIRECTIVES] 添加到我的 @Page 并添加相应的导入,但这并不能解决问题.

                  I've tried implementing it on a ion-input and ion-select and that just works fine. I also tried adding directives: [FORM_DIRECTIVES] to my @Page and added the corresponding import but that doesn't fix the problem.

                  有什么想法吗?

                  推荐答案

                  语法已经改写,ngModel 应该放在 ion-list &radio-group 只有一次.无需将它们放在每个 ion-radio 元素上.

                  Syntax has been changed rewritten now, ngModel should be place with ion-list & radio-group only once. No need to have them there on each ion-radio element.

                  <ion-list radio-group [(ngModel)]="unit">
                      <ion-list-header>
                          Unit
                      </ion-list-header>
                  
                      <ion-item>
                          <ion-label>Metric (kg)</ion-label>
                          <ion-radio value="1"></ion-radio>
                      </ion-item>
                  
                      <ion-item>
                          <ion-label>Imperial (lbs)</ion-label>
                          <ion-radio value="2" ></ion-radio>
                      </ion-item>
                  </ion-list>
                  

                  有关更多信息,您可以访问 ionic2 框架论坛链接

                  For more information you could visit ionic2 framework forum link

                  这篇关于如何在离子无线电元件上使用 ngModel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Ionic2 错误:“没有存储提供程序" 下一篇:如何处理“Go"/“Enter"键盘按钮 Ionic2 <

                  相关文章

                  最新文章

                • <i id='fOXh3'><tr id='fOXh3'><dt id='fOXh3'><q id='fOXh3'><span id='fOXh3'><b id='fOXh3'><form id='fOXh3'><ins id='fOXh3'></ins><ul id='fOXh3'></ul><sub id='fOXh3'></sub></form><legend id='fOXh3'></legend><bdo id='fOXh3'><pre id='fOXh3'><center id='fOXh3'></center></pre></bdo></b><th id='fOXh3'></th></span></q></dt></tr></i><div id='fOXh3'><tfoot id='fOXh3'></tfoot><dl id='fOXh3'><fieldset id='fOXh3'></fieldset></dl></div>

                  <small id='fOXh3'></small><noframes id='fOXh3'>

                    <legend id='fOXh3'><style id='fOXh3'><dir id='fOXh3'><q id='fOXh3'></q></dir></style></legend>
                    <tfoot id='fOXh3'></tfoot>
                      <bdo id='fOXh3'></bdo><ul id='fOXh3'></ul>