简体   繁体   English

在angularjs中管理登陆到家庭过渡的正确方法

[英]Proper way to manage landing to home transition in angularjs

I'm working on a single page app and I wonder how I should manage the transition from the landing to the home. 我正在开发一个单页应用程序,我想知道如何管理从着陆到房屋的过渡。

Both views have a very different layout. 两种视图的布局都非常不同。 The landing allows the user to register or log (exactly like twitter or facebook landing pages). 该登陆允许用户注册或登录(就像Twitter或Facebook登陆页面一样)。 The home displays the content of my website and the information about the logged in user. 主页显示我网站的内容以及有关已登录用户的信息。

What is the best way to handle this with angular? 用angular处理此问题的最佳方法是什么? Do I make two different angular apps (one for landing and one for home)? 我是否制作两个不同的角度应用程序(一个用于着陆,一个用于家庭)? Or only one? 还是只有一个? I'm planning to use ui-router. 我打算使用ui-router。 Once the user is connected and has checked "Remember me", he shouldnt be able to go back to the landing, and will always be redirected to the Home page ( except if he disconnects, of course ). 与用户建立连接并选中“记住我”后,他就不应该返回登录页面,并且总是会重定向到主页(当然,除非他断开连接)。

Thank you 谢谢

I would recommend against using Angular for your landing page, because it will force the download of your entire app just to view that landing page. 我建议不要将Angular用于您的目标网页,因为这将迫使您下载整个应用程序只是为了查看该目标网页。

In my case I have a landing page under /frontend, where it includes all of the html, css, and javascript needed for that page (I even went so far as to add a Ghost blog here). 就我而言,我在/ frontend下有一个登陆页面,其中包含该页面所需的所有html,css和javascript(我什至甚至在这里添加了一个Ghost博客)。 So Angular is only loaded when someone clicks the 'login' or 'register' button. 因此,只有在有人单击“登录”或“注册”按钮时才加载Angular。

I have two .html pages in my root /app directory - one is app.html and one is frontend.html, and I use Node.js/Express to route between them. 我的根目录/ app目录中有两个.html页面-一个是app.html,一个是frontend.html,并且我使用Node.js / Express在它们之间进行路由。 That's the tricky part. 那是棘手的部分。 Here's the express code: 这是快递代码:

// Frontend Homepage & Blog
app.get('/', function (req, res, next) {
  res.sendFile("frontend.html", {root: root + process.env.APP_PATH});
});

// Backend App
app.get('/*', function (req, res, next) {
  res.sendFile("app.html", {root: root + process.env.APP_PATH});
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM