6

I've been developing a mean.js application. 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
  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.

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)

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

admin.index.server.view.html 

and

admin.layout.server.view.html

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);
};

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
   });
};

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

Ronak Jain
  • 1,723
  • 2
  • 24
  • 35
  • What view engine are you using on the server? How much server-side rendering are you doing, generally? Is it a single page app or more 'standard' just enhanced w/ angular? – Paul Dec 29 '14 at 06:43
  • Hi, I'm using the standard Mean.js Stack, Also its a single Page application. I don't have server side render, they are all angular routes and views. but I want to have two seperate server Index files, to separate assets from each other. – Ronak Jain Dec 29 '14 at 08:32
  • Did you ever get this working? – Dave3of5 Sep 02 '15 at 21:40

1 Answers1

0

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.

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

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

tkounenis
  • 665
  • 4
  • 18