ale*_*exP 17 javascript jquery angularjs
我有notifications.get()一个每10秒运行一次的功能.
function notificationsCtrl($scope, $interval) {
$interval(function(){
$scope.notification = notifications.get();
$('.card').addClass('rotate');
}, 10000);
};
Run Code Online (Sandbox Code Playgroud)
但是当加载页面时,应该立即调用该函数.谁能帮我?
Pra*_*lan 47
你可以这样做,
$interval()每10秒执行一次.码:
function notificationsCtrl($scope, $interval) {
var fun = function(){
$scope.notification = notifications.get();
$('.card').addClass('rotate');
};
fun();
$interval(fun, 10000);
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11821 次 |
| 最近记录: |