I want my app to start with www.abc.com/#!/abc currently when I type www.abc.com it redirects to www.abc.com/#!. Following are my 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;
}]);
I tried changing the routes templateurl from
$stateProvider
.state('home', {
url: '/',
templateUrl: 'public/system/views/index.html'
})
to
$stateProvider
.state('home', {
url: '/',
templateUrl: 'public/abc/views/abc.html'
})
which solved my problem from functionality point of view but can I aswell redirect to another url from inside system/views/index.html?
在您的配置部分添加$urlRouterProvider
依赖$urlRouterProvider
$urlRouterProvider.when('/', '/abc');
Yes, you can redirect to other url's (called states in ui-router terminology!). This is how you do it...
In index.html file
<button type="button" ui-sref="login">Go to login state</button>
In controller
.state('login', {
url: "/login",
templateUrl: "views/login.html"
})
Create login.html file
<!-- views/login.html -->
<section data-ng-controller="LoginController">
<h1 mean-token="'login-default'">This is the login view</h1>
</section>
And voila!
You can learn a lot more here !
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.