Angularjs 角度范围参考不工作
在下图中,ng show div不工作。我从另一个div引用它,但在控制器中。请帮忙Angularjs 角度范围参考不工作,angularjs,angularjs-scope,angularjs-ng-repeat,prototypal-inheritance,Angularjs,Angularjs Scope,Angularjs Ng Repeat,Prototypal Inheritance,在下图中,ng show div不工作。我从另一个div引用它,但在控制器中。请帮忙 <div ng-controller="MainCtrl" > <div data-ng-repeat="choic in choice" > <form > <input ng-model="mustShow" class="label_align" type="radio" name="customer" value="no" > <div cla
<div ng-controller="MainCtrl" >
<div data-ng-repeat="choic in choice" >
<form >
<input ng-model="mustShow" class="label_align" type="radio" name="customer" value="no" >
<div class="mediumSubhead"> Information housed </div>
<br/>
<input ng-model="mustShow" class="label_align" type="radio" name="customer" value="yes" >
<div class="mediumSubhead"> Information housed outside </div>
</form>
</div>
<div ng-show="mustShow == 'yes'" > ----this part doesnt work
<input name="first_name" class="text_box_space" type="text" value="" style="color: black;" size="25" width="200px" >
</div>
</div>
Controller.js
var app = angular.module('EquityCompensation', []);
app.controller('MainCtrl', function($scope) {
$scope.choice = [{id: 'choic1'}];
});
资料室
外部信息
----这部分不行
Controller.js
var app=角度。模块('EquityCompensation',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.choice=[{id:'choic1'}];
});
您在ng repeat
内声明ng model
,这是在ng repeat
范围内添加范围变量,因为ng repeat
在每次迭代中都会创建一个新范围。您可以通过使用$parent
符号指向父范围变量来引用父范围
ng-model="$parent.mustShow"
备选方案
您可以使用点规则来使用原型继承,如
$scope.option = {
'mustShow': false
}
然后使用likeng model=“option.mustShow”