标签:des os io for ar 问题 div cti html
.directive("dyName", [ function() { return { require: "ngModel", link: function(scope, elm, iAttrs, ngModelCtr) { ngModelCtr.$name = scope.$eval(iAttrs.dyName) var formController = elm.controller(‘form‘) || { $addControl: angular.noop }; formController.$addControl(ngModelCtr); scope.$on(‘$destroy‘, function() { formController.$removeControl(ngModelCtr); }); } }; } ])
<div ng-repeat="item in demo.fields"> <div class="control-group"> <label class="control-label"> : </label> <div class="controls"> <input type="number" dy-name="item.field" ng-model="demo.data[item.field]" min="10" max="500" ng-required="true"/> </div> </div> </div>
AngularJS 进阶(二) 解决form验证时ng-repeat不能先解析name值问题
标签:des os io for ar 问题 div cti html
原文地址:http://my.oschina.net/sourcecoding/blog/306856