2
我有这个指令,使用服务“BoxService”采取一定的价值。刷新角度指令
angular.module("App").directive('boxedWidget',
function() {
return {
restrict: 'E',
scope: {
'source': '=',
},
replace:true,
templateUrl: '/widgets/box/widget.html',
link: function (scope, element, attrs) {
scope.item = scope.source;
boxService
.getBoxeValue(scope.item.id)
.success(function(data, status, headers, config) {
scope.item.value = data;
});
}
}
});
现在我想刷新每5秒的值。 有什么建议吗?
我刚刚尝试'setInterval(scope.changeValue(),5000);' – user5917414
它不一样。 '$ interval'会导致刷新'范围'。 'setInterval'不。 –
是@ user5917414 ... Mosh Feu是对的这是非常基本但非常重要的区别。 – CandleCoder