TemplateDriven窗体中的值不能以角度更改视图

时间:2018-09-11 07:47:51

标签: angular forms

代码在下面。当我选择selectedConfig.isDataRequest的值时,希望模板会根据selectedConfig.isDataRequest的值进行更改,但似乎无法使用。

<nz-form-item class="dct-col-24">
          <nz-form-label nzSpan="8">数据来源</nz-form-label>
          <nz-form-control nzSpan="16">
            <nz-radio-group [(ngModel)]="selectedConfig.isDataRequest">
              <label nz-radio [nzValue]=0>默认值</label>
              <label nz-radio [nzValue]=1>固定值</label>
            </nz-radio-group>
          </nz-form-control>
        </nz-form-item>
        <ng-template *ngIf="selectedConfig.isDataRequest==0">
          <nz-form-item class="dct-col-24">
            <nz-form-label nzSpan="8">数据值</nz-form-label>
            <nz-form-control nzSpan="16">
              <nz-select nzAllowClear [(ngModel)]="selectedConfig.defaultValue">
                <nz-option [nzLabel]="'test1'" [nzValue]="1">
                </nz-option>
                <nz-option [nzLabel]="'test2'" [nzValue]="2">
                </nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
        </ng-template>
        <ng-template *ngIf="selectedConfig.isDataRequest==1">
          <nz-form-item class="dct-col-24">
            <nz-form-label nzSpan="8">数据值</nz-form-label>
            <nz-form-control nzSpan="16">
              <input nz-input [(ngModel)]="selectedConfig.defaultValue">
            </nz-form-control>
          </nz-form-item>
        </ng-template>

0 个答案:

没有答案