Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在angularjs中将根页面重定向到另一个url_Javascript_Angularjs_Redirect - Fatal编程技术网

Javascript 如何在angularjs中将根页面重定向到另一个url

Javascript 如何在angularjs中将根页面重定向到另一个url,javascript,angularjs,redirect,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> <

我希望我的应用程序以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;
}]);


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

在您的配置部分添加对
$urlRouterProvider


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

是的,您可以重定向到其他url(在ui路由器术语中称为状态!)。你就是这样做的

在index.html文件中

<button type="button" ui-sref="login">Go to login state</button>
<!-- views/login.html -->
<section data-ng-controller="LoginController">
        <h1 mean-token="'login-default'">This is the login view</h1>
</section>
创建login.html文件

<button type="button" ui-sref="login">Go to login state</button>
<!-- views/login.html -->
<section data-ng-controller="LoginController">
        <h1 mean-token="'login-default'">This is the login view</h1>
</section>

这是登录视图

你可以学到更多

OP使用的是angular UI的“UI路由器”,因此是“UI路由器”依赖项!
<!-- views/login.html -->
<section data-ng-controller="LoginController">
        <h1 mean-token="'login-default'">This is the login view</h1>
</section>