如何更改/设置使用约曼与角Fullstack主视图 [英] How to change/set the main view using Yeoman with Angular Fullstack

查看:181
本文介绍了如何更改/设置使用约曼与角Fullstack主视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建使用约曼(角fullstack)的项目。现在我想知道的改变/如何设置login.html的主视图。所以,当你启动应用程序,通常首先获得主视图,您可以选择登录或注册。当应用程序启动页面开始直接上的login.html我要的是

I created a project using Yeoman (angular-fullstack). And now I would like to know how the change/set the main view to login.html. So normally when you start the application you first get the main view where you can chose to login or register. What I want is when the application start the page starts direct on the login.html

推荐答案

我知道这已经在这里一段时间,你可能已经有了一个很好的解决方案,但我最近在看这自己,看到一对夫妇的选择。

I realize this has been out here for a while and you likely already have a good solution, but I was recently looking at this myself and see a couple options.

一,内部app.js你可以在$ urlRouterProvider添加以下code片断:

One, inside app.js you could add the following code snippet under $urlRouterProvider:

.when('/', '/login')

让您完整的方法是这样的:

Making your full method be something like:

.config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) {
    $urlRouterProvider
       .when('/', '/login')

    $locationProvider.html5Mode(true);
    $httpProvider.interceptors.push('authInterceptor');
})

这将迫使任何人要你的基本页面的URL直接登录,除非它们提供给另一个页面的完整路径。但是,如果您打算仍然使用main.html中,您将需要进入的客户机/应用/主/ main.js并更改默认路由为:

This would force anyone going to your base page url directly to login, unless they provide the full route to another page. However, if you intend to still use the main.html, you will then need to go into client/app/main/main.js and change the default route to:

.state('main', {
    url: '/main',
    templateUrl: 'app/main/main.html',
    controller: 'MainCtrl'
 });

所以主要是通过追加/主到URL访问。

So main is reachable by appending /main to the url.

这使我选择2:进入的main.js文件,并打开它的URL为/主,进入login.js并切换它的URL为'/'。那么任何人都浏览到你的基地页面自动进入登录画面,但该URL被视为只是你的域,而无需任何的子页面。

Which brings me to option 2: Go into the main.js file and switch it's url to '/main' and go into login.js and switch it's url to '/'. Then anyone navigating to your base page automatically goes to the login screen but the url is viewed as just your domain without any sub page.

所以,客户端/应用/主/ main.js就变成了:

So client/app/main/main.js becomes:

.state('main', {
    url: '/main',
    templateUrl: 'app/main/main.html',
    controller: 'MainCtrl'
 });

和客户端/应用/帐号/ account.js现在包含:

And client/app/account/account.js now contains:

.state('login', {
    url: '/',
    templateUrl: 'app/account/login/login.html',
    controller: 'LoginCtrl'
 })

这篇关于如何更改/设置使用约曼与角Fullstack主视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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