我是Angular的新手,非常感谢您的建议。我使用ui.router
并配置了这样的状态:
app.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise("/category");
$stateProvider
.state('category', {
url: '/category',
templateUrl: 'category.html',
controller: 'categoryController as catCtrl',
reload: true
})
.state('category.categoryDetail', {
url:'/:id',
templateUrl: 'categoryDetail.html',
controller: 'categoryDetailController as catDetailCtrl',
})
.state('category.categoryDetail.product', {
url:'/product/:prod_id/:filter_model/:current_page',
templateUrl: 'product.html',
controller: 'productController as productCtrl'
})
我需要设置超时功能,检查是否没有针对' n'分钟,然后我需要网站返回默认状态'category'
。我知道我可以使用jQuery
使用setTimeout()
进行此操作,但我不确定嵌入代码的位置。
答案 0 :(得分:3)
我相信你需要像ng-idle
这样的东西答案 1 :(得分:1)
您可以使用app.run
。
我在plunker中提供了一个例子:https://plnkr.co/edit/aHj3XeCC83hHoCcu9Vix?p=preview
复制代码并在本地试用,它会正常工作。