目前我有一个包含嵌套ng-repeat的HTML页面,我在内部ng-repeat中有一个名为“isExpand”的变量。我想知道有没有办法从控制器修改“isExpand”?
以下是演示HTML布局:
<div ng-repeat="(key, value) in menus">
<div> {{key}} </div>
<div ng-repeat="item in value">
<div >
<img class="title-col-img" ng-show="!isExpand" src="img/Close.png" ng-click="isExpand = true">
<img class="title-col-img" ng-show="isExpand" src="img/Open.png" ng-click="checkContentChanged(item)">
<div class="title-col-text" > {{item.name || 'empty'}} </div>
</div>
<div ng-click="isExpand = true">
C<textarea ng-show="isExpand" ng-model="item.field1"> </textarea>
</div>
<div class="description-col col-md-4" ng-click="isExpand = true">
<textarea ng-show="isExpand" ng-model="item.field2"> </textarea>
</div>
</div>
</div>
答案 0 :(得分:0)
当然:将它作为您正在迭代的数组的当前元素的字段:
<div ng-repeat="item in value">
<div>
<img class="title-col-img" ng-show="!item.isExpanded" src="img/Close.png" ng-click="item.isExpanded = true">
</div>
...
</div>