简体   繁体   English

当输入类型=“ number”相同时,在ng-repeat内部动态设置ng-model并使其单选按钮不起作用

[英]Setting ng-model dynamically inside ng-repeat with radio button not working, when same with input type=“number” working properly

I am using ng-repeat where I have to put ng-model in dynamic way. 我在使用ng-repeat时必须以动态方式放置ng-model。 Code is as follow; 代码如下:

<div class="panel panel-default" ng-repeat="(key, value) in $parent.shared.sourceSchema">
    <div class="panel-heading">
        <h4 class="panel-title">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapse1">
            {{value.sourceName}}
        </a>
        </h4>
    </div>
    <div id="collapse1" class="panel-collapse collapse in">
        <div class="panel-body">
            <div ng-repeat="col in value.columns">
                <input ng-model=$parent.value[sourceSrNo] type="radio">{{col.column}}
            </div>
        </div>
    </div>
</div>

My $parent.shared.sourceSchema is as follow; 我的$ parent.shared.sourceSchema如下;

Object {1: Object}
   1:Object
       columns:Array[7]
       sourceName:"S3"
       sourceSrNo:1
       __proto__:Object

But the at the applied ng-model is not working. 但是所应用的ng模型无法正常工作。

I tried in different way as follow; 我以不同的方式尝试如下:

ng-model=$parent.value[sourceSrNo];
ng-model=value[sourceSrNo];
ng-model={{$parent.value[sourceSrNo]}};
ng-model={{value[sourceSrNo]}};
ng-model=$parent.value.sourceSrNo;
ng-model=value.sourceSrNo;
ng-model={{$parent.value.sourceSrNo}};
ng-model={{value.sourceSrNo}};

ng-model="$parent.value[sourceSrNo]";
ng-model="value[sourceSrNo]";
ng-model="{{$parent.value[sourceSrNo]}}";
ng-model="{{value[sourceSrNo]}}";
ng-model="$parent.value.sourceSrNo";
ng-model="value.sourceSrNo";
ng-model="{{$parent.value.sourceSrNo}}";
ng-model="{{value.sourceSrNo}}";

None of those worked for me. 这些都不对我有用。

I want to keep same ng-model value for each outer ng-repeat 我想为每个外部ng-repeat保留相同的ng-model值

the result of ng-model="$parent.value.sourceSrNo" is as follow; ng-model =“ $ parent.value.sourceSrNo”的结果如下;

在此处输入图片说明

尝试将$ parent.value [sourceSrNo]替换为value.sourceSrNo

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

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