我有一个自定义的父指令,其中有一个数组applicantData
。从下面的代码中可以看到,我使用了ng-repeat
指令。我可以从父指令访问enabledEdit[]
数组。据我所知,子范围不能直接访问父范围。那么,为什么这对我来说有效呢?
<tr ng-repeat="person in applicantData">
<td>
<input ng-model="person.Name" ng-disabled="!enabledEdit[{{$index+0}}]" />
</td>
<td>
<input ng-model="person.Title__c" ng-disabled="!enabledEdit[{{$index+0}}]" />
</td>
<td>
<select class="fixed-width" ng-model="person.Selection__c" ng-options="d.name as d.name for d in infoDesignationList"
ng-disabled="!enabledEdit[{{$index+0}}]"></select>
</td>
<td>
<input ng-model="person.Email_Address__c" ng-disabled="!enabledEdit[{{$index+0}}]" />
</td>
<td>
<div class="buttons" align="center">
<button class="btn" ng-disabled="isReadOnly" ng-click="editPerson($index+0)"><i class="fa fa-edit"></i></button>
</div>
</td>
</tr>