Based on the answer by Jack.the.ripper, I created this solution.
Casus: I have a slight variation that I actually want 2 layouts. One Public and one Private.
In Meteor with Blaze and Iron Router there was a nice solution that you could just define which master template will be used for a certain route.
This I have now been able to set up thanks to Jack!
NOTE: Code will be in Jade and Coffee and it's a Meteor + Angular project.
Use http://js2.coffee/ to convert to Javascript.
# the ROUTER part
#
angular.module( 'myApp' ).config(
( $urlRouterProvider, $stateProvider, $locationProvider ) ->
$locationProvider.html5Mode true
$stateProvider
.state( 'private',
url: ''
abstract: true
views:
'app':
templateUrl: 'client/views/layouts/privateLayout.html'
)
.state( 'public',
url: ''
abstract: true
views:
'app':
templateUrl: 'client/views/layouts/publicLayout.html'
)
.state( 'private.home',
url: '/'
views:
"container@private":
templateUrl: 'client/views/home/home.html'
)
.state( 'public.login',
url: '/login'
views:
"container@public":
templateUrl: 'client/views/session/login.html'
)
$urlRouterProvider.otherwise '/'
)
This is the index file where the app view is defined that will utilise the abstract state defined in the router.
head
meta(name="viewport" content="width=device-width, initial-scale=1")
base(href="/")
body(layout="column")
div(ui-view="app" layout="column" flex)
Then the Private Layout with its container view.
div(layout="column" flex)
div(ng-controller="AppCtrl" layout="row" flex)
//- some private Layout stuff happening here....
md-content(flex layout-padding)
div(ui-view="container" layout="column")
and finally the Public Layout with its container view
div.public-layout(layout="column" flex)
div(ui-view="container" layout="column" flex)
With this setup I can set the login page to use the abstract public layout by stating in the view of this route that it should uses views container@public, meaning from Public view, use the view Container. In this view load the login.html.
Same goes for the home page, this one loads the container@private meaning the Container view of the Private view.
This seems to work like a charm.
Thanks very much Jack, and also the author of the answer on Angular UI Router - Nested States with multiple layouts which helped me to get towards the final solution.
Cheers