There is a list of objects, you need to follow the changes in their properties. Since the server is not configured for sockets, it is necessary to use cyclic requests, that is, I perform the function from the controller every second, but this causes strange program behavior, selected checkboxes fly off.
A function that repeats:
function getDeviceList() { var data = { UserSID: store.get('currentUserSID'), Limit: 100, StartToken: 0 }; DeviceService.GetDeviceList(data) .then(function(response) { vm.devices = response.data.Device; }, function(error) { vm.error = error.data; }) }; setInterval(getDeviceList, 1000);
Initialization in html:
<div class="part" ng-init="vm.getDeviceList()"> <div ng-repeat="filt in filters"> <h1 ng-click="show =! show" class="part__title " ng-class="{'is-active': !show }" ng-hide="!(vm.devices|{{filt.filterName}}).length">{{filt.name}} <label> <span class="part__multi-check"> <input class="part__all-check" type="checkbox" ng-model= "masterChecked" ng-click = "vm.toggleAll(itemsResults, masterChecked)" ng-checked = "vm.getCheckedCount(itemsResults) == itemsResults.length && itemsResults.length > 0"> <svg class="icon part__icon--all-check part__icon--check"> <use xlink:href="#icon-сheckmark"></use> </svg> <input class="part__intermed-checkbox" type="checkbox" ng-checked ="vm.getCheckedCount(itemsResults) < itemsResults.length && vm.getCheckedCount(itemsResults) != 0 && itemsResults.length > 0"> <span class="part__intermed-check"> </span> </span> </label> </h1> <div class="part__content " ng-class="{'is-active': !show }" ng-hide="!(vm.devices|{{filt.filterName}}).length"> <div class="part__item" ng-repeat="item in (vm.devices|applyFilter: filt.filterName) | filter: query as itemsResults" ng-click="choose =! choose "> <svg class="icon part__icon is-active{{item.HealthStatus}}" ng-class="{'is-checked': choose} "> <use xlink:href="{{'#icon-'+ item.Name}}"></use> </svg> <p class="part__text" ng-bind="item.Name"> <br>(00:AE:02:2C) </p> <label class="part__check"> <input type="checkbox" ng-model="item.isChecked" value="{{item.Name}}" class="part__radio" /> <span class="part__checkmark"> <svg class="icon part__icon--check" > <use xlink:href="#icon-сheckmark"></use> </svg> </span> </label> </div> </div> </div> </div>
ng-hide="!(vm.devices|{{filt.filterName}}).length"
even had the same question ru.stackoverflow.com/questions/549446/… - Grundy