javascript - 如何将根页面重定向到angularjs中的另一个url

标签 javascript angularjs redirect

我希望我的应用以 www.abc.com/#!/abc 开头,目前当我键入 www.abc.com 时它会重定向到 www.abc.com/#!。以下是我的 index.html

<!-- views/index.html -->
<section data-ng-controller="IndexController">
    <h1 mean-token="'home-default'">This is the home view</h1>
</section>


// controllers/index.js
angular.module('mean.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) {
    $scope.global = Global;
}]);

我尝试更改路由 templateurl 来自

        $stateProvider              
            .state('home', {
                url: '/',
                templateUrl: 'public/system/views/index.html'
            })

        $stateProvider              
            .state('home', {
                url: '/',
                templateUrl: 'public/abc/views/abc.html'
            })

这从功能的 Angular 解决了我的问题,但我也可以从 system/views/index.html 中重定向到另一个 url 吗?

最佳答案

在你的配置部分添加对$urlRouterProvider的依赖

$urlRouterProvider.when('/', '/abc');

关于javascript - 如何将根页面重定向到angularjs中的另一个url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23930161/

相关文章:

http - nginx 将每个 http 请求重定向到 https

php - 拉维尔 5 : Use 301 instead of 302

javascript - Grunt usemin 未找到目标

javascript - 如何将数组对象绑定(bind)到 FullCalendar 事件?

javascript - 循环和变量中的 Event.observe

javascript - 从 javascript 打印 iframe 在终端服务器上的 IE 中不起作用

javascript - 如何将 'this' 传递给 setTimeout 回调

javascript - Firebase 多次登录用户

javascript - 将 href 与 ng-click 结合使用

apache - 将子域重定向到另一种语言的获取查询字符串.htaccess