我有以下问题:我有一个父复选框和其他孩子。如果我使用 ng-model 父级,则在 ng-check 中检查它们,直到它工作正常。当想知道 ng-change 属性是否已更改时,我在单击子复选框之前不会得到结果。
看法
<ul class="collapsible" data-collapsible="accordion" watch>
<li ng-repeat="fleet in fleets">
<div class="collapsible-header"><i class="material-icons">send</i>
<input type="checkbox"
class="filled-in"
id="{{fleet.nameFleet}}"
ng-model="fleetObject[fleet.nameFleet]" />
<label for="{{fleet.nameFleet}}">{{fleet.nameFleet}}</label>
</div>
<div class="collapsible-body">
<p ng-repeat="item in fleet.vehicles | filter:search">
<input type="checkbox"
class="filled-in"
id="{{item.nameVehicle}}"
ng-checked="fleetObject[fleet.nameFleet]"
ng-model="vehicleObject[item.nameVehicle]"
ng-change="viewVehicle()"/>
<label for="{{item.nameVehicle}}">{{item.nameVehicle}}</label>
</p>
</div>
</li>
</ul>
{{fleetObject | json}}
<br>
{{vehicleObject | json}}
控制器
myApp.controller('fleets', function ($scope, $http, sharedProperties) {
var idFleet = sharedProperties.getProperty();
$scope.fleetObject = {};
$scope.vehicleObject = {};
//
$http.get(myUrl + 'AppVehicle/' + idFleet).then(function (response) {
if (response.data.length != 0) {
$scope.fleets = response.data;
Materialize.toast('Flotas obtenidas', 2000);
}
else {
Materialize.toast('No se encontraron Flotas', 2000);
}
})
//
$scope.viewVehicle = function(){
console.log('obj');
}});
拜托,你能帮我检查一下父复选框获取孩子的名字吗?已经非常感谢