Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度范围参考不工作_Angularjs_Angularjs Scope_Angularjs Ng Repeat_Prototypal Inheritance - Fatal编程技术网

Angularjs 角度范围参考不工作

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

在下图中,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 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
}
然后使用like
ng model=“option.mustShow”