简体   繁体   English

Mean.js多个布局,服务器或角度布局

[英]Mean.js Multiple Layouts, Server or Angular Layout

I've been developing a mean.js application. 我一直在开发一个mean.js应用程序。 I have an admin theme that I'm trying to integrate with the existing application. 我有一个管理主题,我正在尝试与现有的应用程序集成。

My question is 我的问题是

  1. Can we have multiple Server Layouts, ? 我们可以有多个服务器布局吗? If the logged-in user is Regular User, use layout-1 if the user is Admin use layout-2 如果登录用户是普通用户,如果用户是Admin,则使用layout-1 layout-2
  2. If we cannot have multiple server layout (I presume it isn't possible). 如果我们不能有多个服务器布局(我认为这是不可能的)。 Is there any way to detect the params or scope variable in the Angular Client App and dynamically load a partial inside the main Layout. 有没有办法检测Angular Client App中的params或scope变量,并在主Layout中动态加载部分。

Let say I have an Index.html file, if the intended route is Dashboard, I just replace a section of the page view, ( Ruby on Rails Developers would know this) 假设我有一个Index.html文件,如果预期路由是Dashboard,我只是替换页面视图的一部分,(Ruby on Rails Developers会知道这个)

UPDATE 1 : I've created 2 files with my required Admin Index, and Layout files. 更新1 :我用我需要的管理员索引和布局文件创建了2个文件。

admin.index.server.view.html 

and

admin.layout.server.view.html

I've also added the following code in my core.server.routes.js 我还在core.server.routes.js中添加了以下代码

module.exports = function(app) {
   // Root routing
   var core = require('../../app/controllers/core');
   app.route('/').get(core.index);
   app.route('/admin/').get(core.adminIndex);
};

I've also added the following code in my core.server.controller.js 我还在core.server.controller.js中添加了以下代码

exports.adminIndex = function(req, res) {
   res.render('admin.index', {
       user: req.user || null
   });
};

and when I hit localhost:3000/admin/ I get Error: Cannot find module 'index' 当我点击localhost:3000 / admin /我得到错误:找不到模块'索引'

Rename the two view files from admin.index.server.view.html and admin.layout.server.view.html to admin-index.server.view.html and admin-index.server.view.html respectively. admin.index.server.view.htmladmin.layout.server.view.html的两个视图文件分别重命名为admin-index.server.view.htmladmin-index.server.view.html

Also, change this line in your core.server.controller.js file; 另外,在core.server.controller.js文件中更改此行; res.render('admin.index', {

to this; 对此; res.render('admin-index', {

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

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