我正在使用Restangular从Web服务中提取数据。 之后,我为该系列添加了一块手表。 这将触发一次,并且比较newVal和oldVal也会证明不平等,但即使是深度差异也没有区别。
var addWatch = function($scope) {
$scope.$watchCollection('model.organisation', function (newVal, oldVal) {
if(newVal !== oldVal) {
console.log("MODEL CHANGE") // ONCE on initialization but I cannot find any difference
}
});
};
var OrganisationCrudCtrl = ['$scope', '$rootScope', '$stateParams', 'Restangular', 'StateService', function ($scope, $rootScope, $stateParams, Restangular, S
var stateRef = StateService.get();
$scope.model = stateRef;
if ($stateParams.slug) {
Restangular.one('organisation', $stateParams.slug).get().then(function (organisation) {
// The service stores the object for further use
StateService.setOrganisation(organisation.data);
// The watch is added
addWatch($scope);
});
}
}];