3

My setup

app/learning/learning.js

 angular.module('meanApp')
.config(function($stateProvider) {
  $stateProvider
  .state('learning',{
    templateUrl: 'app/learning/learning.html',
    url: '/learning',
    controller: 'LearnCtrl',
    views: {
     'list': {
       templateUrl: 'app/learning/learning.list.html',
       controller: function($scope){  }
     },
     'magic': {
       templateUrl: 'app/learning/learning.magic.html',
       controller: function($scope){  }
     }
   }
 });
});

app/learning/learning.html

<h1>Learning</h1>
<div ui-view="list"></div>
<div ui-view="magic"></div>

app/learning/learning.list.html

<p>A list</p>

app/learning/learning.magic.html

<h2>Magic</h2>

when I navigate to /learning I get a blank page, I'm not sure what I'm doing wrong so any help would be greatly appreciated.

2 Answers 2

2

You shouldn't load the base template inside state when there are nested ui-view, Define the base template inside views.

Route Code

 angular.module('meanApp')
.config(function($stateProvider) {
  $stateProvider
  .state('learning',{
    url: '/learning',
    views: {
     '': {
       templateUrl: 'app/learning/learning.html',
       controller: 'LearnCtrl'
     },
     'list@learning': { //you missed state name here
       templateUrl: 'app/learning/learning.list.html',
       controller: function($scope){  }
     },
     'magic@learning': { //you missed state name here
       templateUrl: 'app/learning/learning.magic.html',
       controller: function($scope){  }
     }
   }
 });
});

This could Help you, Thanks.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you so much, that has been bugging me for ages!
@Cherry15 You're welcome, it would be great if you marked answer as correct.
Sorry, just discovered the tick next to the answer, I'm new to stackoverflow
@Cherry15 np. Thanks once again :)
0

The problem was that I was trying to load the base template inside state and I missed out the state name as Pankaj said, so the solution is...

angular.module('meanApp')
.config(function($stateProvider) {
 $stateProvider
 .state('learning',{
   url: '/learning',
   views: {
     '': {
     templateUrl: 'app/learning/learning.html',
     controller: 'LearnCtrl'
    },
    'list@learning': { //you missed state name here
     templateUrl: 'app/learning/learning.list.html',
     controller: function($scope){  }
    },
    'magic@learning': { //you missed state name here
     templateUrl: 'app/learning/learning.magic.html',
     controller: function($scope){  }
    }
  }
 });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.