ng-options disabled in array

75 Views Asked by At

I have a view that manages school's tests in a period (trimester or semester). Each semester can have many tests of type normal but only one of type examen.

I have made a script in jsFiddle that shows the behavior I am looking for https://jsfiddle.net/dfLf9zkm/.

The difference is that in the ng-repeat I have a ng-controller over each test so every time I called the ng-method it only affects the row I am on and not the rest. Something like

<div ng-app="app" ng-controller="Controller">
    <table>
        <tr>
            <th>Type</th>
            <th>Ponderation</th>
        </tr>
        <tr ng-repeat="test in tests track by test.id" ng-controller="TestRow">
            <td><select ng-model="test.type" ng-options="type.id as type.type disable when type.id == 2 && hasExam && idExam!=test.id for type in types" ng-change="checkTests()"></select>
            </td>
            <td>{{test.ponderation}}%</td>
        </tr>
    </table>
</div>

If I change the value of $scope.hasExam with a method inside TestRow controller it only affect that row and not the rest. How can I do it?

1

There are 1 best solutions below

0
On

I finally decided to leave everything in one controller and that fixed everything up