Mean.js多种布局,服务器或角布局 [英] Mean.js Multiple Layouts, Server or Angular Layout

查看:164
本文介绍了Mean.js多种布局,服务器或角布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个应用程序mean.js。我有我试图与现有应用程序集成的管理主题。

I've been developing a mean.js application. I have an admin theme that I'm trying to integrate with the existing application.

我的问题是


  1. 我们可以拥有多个服务器布局,?如果登录的用户是普通用户,利用布局-1如果用户是管理员使用布局2

  2. 如果我们不能有多个服务器的布局(我presume这是不可能的)。有什么方法来检测角客户端应用程序的PARAMS或范围的变量,并动态加载的部分主要布局中。

让说我有一个index.html文件,如果预定航线是仪表板,我只需更换页面视图的一部分,(Ruby on Rails的开发者都知道这一点)

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)

更新1
我创建了2个文件我需要的管理指标,和布局文件。

UPDATE 1 : I've created 2 files with my required Admin Index, and Layout files.

admin.index.server.view.html 

admin.layout.server.view.html

我还添加以下code在我core.server.routes.js

I've also added the following code in my 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);
};

我还添加以下code在我core.server.controller.js

I've also added the following code in my core.server.controller.js

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

和时,我打本地主机:3000 /管理/我得到错误:无法找到模块索引

and when I hit localhost:3000/admin/ I get Error: Cannot find module 'index'

推荐答案

admin.index.server.view.html 重命名这两个视图文件和 admin.layout.server.view.html 管理​​ - index.server.view.html 管理​​ - index.server.view.html 分别。

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.

另外,更改在 core.server.controller.js 文件这一行;
res.render('admin.index',{

Also, change this line in your core.server.controller.js file; res.render('admin.index', {

本;
res.render('管理指数',{

这篇关于Mean.js多种布局,服务器或角布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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