简体   繁体   English

Angular2 双向绑定与 Semantic ui Slider 复选框

[英]Angular2 two-way binding with Semantic ui Slider checkbox

I have created Semantic UI slider checkbox dynamically by using JSON Schema in Angular2.我通过在 Angular2 中使用 JSON Schema 动态创建了语义 UI 滑块复选框。 I tested Angular2 two-way binding with input box its working fine.but with slider checkbox, it's giving me an error我用输入框测试了 Angular2 双向绑定,它工作正常。但是使用滑块复选框,它给了我一个错误

Cannot read property 'Value' of undefined无法读取未定义的属性“值”

This is my component.html here I'm using two type of slider checkbox one is input type has radio and another one is input type has the checkbox.这是我的 component.html 在这里我使用两种类型的滑块复选框,一种是输入类型有收音机,另一种是输入类型有复选框。

<div *ngFor="let t of arrayTypeArray; let i=index;">
<label>{{LabelToDisplay[i][0]}}</label>
<div *ngFor="let typeLiteral of sementicClass[i];let j=index;" (change)="disp();">
     <div class="ui form"  *ngIf="typeLiteral === 'base' ">
        <div class="grouped fields">   
            <div class="field">
                <div class="ui slider checkbox">
                    <input type="radio" name="throughput" checked="checked" [(ngModel)]="infoData[arrayLabelArrayKeys[i][j]]['Value']"> <!-- error-->
                    <label>{{LabelToDisplay2[i][j]}}</label>
                </div>
            </div>
        </div>
     </div>

    <div class="field" *ngIf="typeLiteral === 'alpha' ">    
        <div class="ui slider checkbox">  
        <input type="checkbox" name="newsletter">
        <label>{{LabelToDisplay2[i][j]}}</label>
        </div>
    </div>
</div>

can Anyone help me how to use two-way binding with semantic ui slider checkbox?任何人都可以帮助我如何使用带有语义 ui 滑块复选框的双向绑定?

Thanks in advance.提前致谢。

Using ngModel you can.使用 ngModel 你可以。

 <div *ngIf="data === 'boolean'">
      <label for="{{labels[i]}}">{{labels[i]}}</label>
      <input type="checkbox" class="checkbox-inline" (change)="getJSON()" [(ngModel)]="model[labels[i]]" name="{{labels[i]}}">
 </div>

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

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