如何在ngRepeat值中设置ngModel(AngularJS)

时间:2015-09-14 21:48:34

标签: javascript angularjs angularjs-ng-repeat angular-ngmodel

在代码上,您可以看到如下:

<div class="form-group form-group-sm" ng-repeat="sForm in sForms">
    <label class="col-sm-3 control-label">{{sForm.label}}</label>
    <div class="col-sm-8">
        <input type="text" class="form-control" placeholder="{{sForm.place}}" name="{{sForm.name}}" ng-model="search[sForm.propertyName]" ng-click="searchDisabled(sForm.val)" ng-disabled="{{sForm.disabled}}" />
    </div>
    <div class="col-sm-1">
        <input type="radio" class="radio" name="checked" ng-click="searchDisabled(sForm.val)" ng-model="formRadio.checked" value="{{sForm.val}}" ng-hide="{{!sForm.disabled}}" />
    </div>
</div>

不适用于ngModel值search[sForm.propertyName]。我不知道为什么..这是属性:

$scope.sForms = [
            {
                label: 'Lastname',
                place: 'Searching lastname',
                name: 'Lname',
                val: 1,
                propertyName: 'lname',
                disabled: $scope.disabledLname,
                hideRadio: !$scope.disabledLname
            },
            {
                label: 'Firstname',
                place: 'Searching firstname',
                name: 'Fname',
                val: 2,
                propertyName: 'fname',
                disabled: $scope.disabledFname,
                hideRadio: !$scope.disabledFname
            }];

禁用值也不起作用。当我检查第一个输入时,需要禁用第二个输入。

0 个答案:

没有答案