If you are creating code outside of angular, you need to say that you are changing something with $ apply
$scope.names = ['Jack'];
append_name = function() {
$scope.$apply(function() {
$scope.names.push('Bob');
});
};
setTimeout(append_name, 2000);
, $apply:
function ngWrap($scope, fn) {
return function() {
var args = [].slice.call(arguments);
if ($scope.$$phase) {
fn.apply(null, args);
} else {
return $scope.$apply(function() {
fn.apply(null, args);
});
}
};
}
:
setTimeout(ngWrap($scope, function() {
$scope.names.push('Bob');
}), 2000);
angular $timeout, .