I have this html code :
<table class="table table-striped table-condensed table-hover">
<tbody>
<tr ng-repeat="doc in container.Documents ">
{{doc.Status.Message}}
</td>
<!-- .... -->
</tr>
</tbody>
</table
and this angularjs controller:
(function (ng, app) {
"use strict";
app.controller(
"my.DocumentsController",
function ( $scope, $stateParams, MYContainer, $timeout ) {
$scope.container = new MYContainer();
$scope.$watch('container', function (newVal, oldVal) {
$timeout(function () {
$scope.$apply();
}, 0);
}, true);
$scope.container.load($stateParams.Id);
});
})(angular, my_app);
the load function of MYContainer:
function load(id) {
var scope = this;
var deffered = $q.defer();
containerService.getData(id, "true").success(function (data) {
angular.extend(this, data);
deffered.resolve();
}).error(function (e) {
deffered.reject('Error while loading container');
});
return deffered.promise;
}
The problem is that whenever I reload the batch (with modified container.Documents) it does not show the modified batch in the html view.
I've read about equality watches in angular so I added the watch function in the controller, and it does detect the modification in the watch function so I call $scope.$apply() but it does not change in html.
If I put 200 ms in the $timeout call instead of 0 the view gets changed.