简体   繁体   English

以特定时间间隔切换选项卡的角度

[英]Switch tab at specific time interval in angular

I want to switch the routes(tabs) at specific time interval. 我想以特定的时间间隔切换路线(标签)。 At every 15 secs routes should be switch. 应该每隔15秒切换一次路线。

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 这是我的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 . 注入$ route并在$route对象中有一个名为$route.routes It's return all defined routes. 它返回所有已定义的路线。 And change above method 并改变上述方法

Angular doc says Angular doc说

routes 路线

Object with all route configuration Objects as its properties. 具有所有路径配置对象的对象作为其属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM