X秒钟后如何在AngularJS中自动重定向? [英] How to auto redirect after X seconds in AngularJS?

查看:61
本文介绍了X秒钟后如何在AngularJS中自动重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AngularJS中执行此操作的正确方法是什么?我没有找到任何简单的答案.

What is the right way to do this in AngularJS? I didn't find any simple answer to this.

我想:

  1. 加载页面
  2. 等待X秒钟
  3. 这些秒后将自动重定向到另一个页面.

注意:我正在使用ui-routing(状态)执行重定向

Note: I'm using ui-routing (states) to perform redirections

谢谢.

推荐答案

这有效(感谢PSL):

This works (thanks PSL):

.controller('SeeYouSoonCtrl', ['$scope', '$state', '$timeout',
                                function($scope, $state, $timeout) {

    $timeout(function() {
      $state.go('AnotherState');
      }, 3000);

    }])

这篇关于X秒钟后如何在AngularJS中自动重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆