简体   繁体   中英

How to use different layout for specific views in sails.js and angular.js

I have a Sails.js + Angular.js project. I am using a single layout for this project. But right now I got different html, and it's layout is totally different from the one I am using right now.

The current layout file I am using is the default one layout.ejs which located at views/layout.ejs. In the layout.ejs file, the header and footer are resuable throught the project, The body part which is <div ng-view></div> , I am using angular.js for this dynamic part. And the angular app file is like:

 function config($routeProvider) {
  $routeProvider.when('/movie', {
    templateUrl: '/templates/movie-list.html',
    controller: 'MovieCtrl'
  }).when('/movie/:id', {
    templateUrl: '/templates/movie-detail.html',
    controller: 'MovieCtrl'
  })
}

Right now, I got 3 htmls which layout is completly different. I still want to add these new html as template file, and put them in the codes above. But how should I separate the layout and make it work?

In your controller you can use the following before sending data.

res.locals.layout = '';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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