Templates within template

Is it possible to use a template inside a template? I keep getting a black screen after loggin in when using templates within templates. I want to display the app without menus on the login screen, but I want to display menus after they log in. Please advise.

    <ion-nav-view name='display'>
        <div>Login Form</div>
    <ion-nav-view name='display'>
        <div>Left Menu Template</div>
        <ion-nav-view name='content'>
                <div>Page Content</div>
        url: '/login',
        views: {
              'display': {
                   templateUrl: 'templates/testing.html'
             'content': {
                   templateUrl: 'templates/testing2.html'

You could use angular’s ng-include https://docs.angularjs.org/api/ng/directive/ngInclude Then set conditions for elements to show based on $scope variables.

A question for you though, why not just take the user to a new screen after they have successfully logged in?

if i understand you right you want something like this:

if not can you explain why not? :smiley:

The problem boils down to not being able to have 2 ion-nav-views. Using ngInclude causes my application to have to use $window.location.reload() whenever a user logs out because ionic/angular caches the ngInclude view and doesn’t honor the ng-show attribute. I’m trying to use side menus when logged in and not show any title or menus when logged out.

<div ng-show="account == null || account == undefined">
  		<ion-nav-view name="display"></ui-nav-view>
	<ng-include src="'templates/other/menus.html'" ng-show="account != null && account != undefined"></ng-include>

I could take the user to another screen. That’s a good thought. I suppose I could use index.html for the login screen and menus.html for the authenticated users.

I should have explained that the menus are side menus. Trying to get side menus to show and hide based on authentication is not easy for me. You’ll likely run into the issue of having 2 ion-nav-view tags. One ion-nav-view tag for the base template and one ion-nav-view tag in your side menu. You can’t have 2 ion-nav-views nested. This is the heart of the problem.

you mean something like this:

and you can have ion-nav-views nested you need to use named once.

the first <ion-nav-view></ion-nav-view> is in the body
the next is in the event-menu template <ion-nav-view name="menuContent"></ion-nav-view>
you could even have more but then it starts to get messy :smiley:

i hope this did help if not could you prove more information.

1 Like

Perfectly done. I was getting messed up on the nested states. Looks like you can have nested states, just not named nested states? I’ll keep experimenting. Thanks!