I want to switch the routes(tabs) at specific time interval. At every 15 secs routes should be switch.
angular.module('InternalDashboardAPP').config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'Home/PendingRotator',
controller: 'PendingRotatorController'
})
.when('/PendingsUncheck', {
templateUrl: 'Home/PendingsUncheck',
controller: 'PendingsUncheckController'
})
.when('/CasePendingsUncheck', {
templateUrl: 'Home/CasePendingsUncheck',
controller: 'CasePendingsUncheckController'
})
.otherwise({
redirectTo: '/'
});
}])
here is my index.cshtml
<div ng-app="InternalDashboardAPP" ng-controller="HomeController">
<div id="mainContentContainer">
<ul class="navigationStyle">
<li class="linkDashboard"><a href="#/">Keyword Pendings</a></li>
<li class="linkActive"><a href="#/PendingsUncheck">Pendings unchecked per hour</a></li>
<li class="linkActive"><a href="#/CasePendingsUncheck">Case Pendings unchecked per hour</a></li>
</ul>
</div>
</div>
在.run
注入$interval
并且只是连续循环每个$route
It's so simple...
Get your defined routes to an array.
var defined_routes = ["/", "foo", "bar"];
for(var i in defined_routes){
setInterval(function(){
$location.path(defined_routes[i]);
}, 15000);
}
Fund a method. $route.routes
Inject $route and there is a property in $route
object called $route.routes
. It's return all defined routes. And change above method
Angular doc says
routes
Object with all route configuration Objects as its properties.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.