app.controller('StdNoticeCtrl', [ '$rootScope', '$scope', '$http', '$timeout', '$state', '$stateParams', '$interval', function($rootScope, $scope, $http, $timeout, $state, $stateParams, $interval) { $scope.startEnrol = function() { $rootScope.goLocation('std/reg'); } $scope.timesStr=10; var times = $interval(function () { if($scope.timesStr==0){ // 取消定时器 $interval.cancel(times); } else { $scope.timesStr--; } },1000); } ])