Javascript 如何在angularjs中将根页面重定向到另一个url
我希望我的应用程序以www.abc.com/#开始/abc当前,当我键入www.abc.com时,它会重定向到www.abc.com/#!。下面是我的index.htmlJavascript 如何在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> <
<!-- 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>