Skip to content Skip to sidebar Skip to footer

Child Route Does Not Trigger

I am building this route system var app = angular.module('plunker', ['ui.router']); app.config(function ($stateProvider, $urlRouterProvider) { $urlRouterProvider .when('/adm

Solution 1:

You were almost there, the updated plunker. There is only one change the nested views do have appended sign '@':

.state('admin.link1', {
  url: '/admin/link1',
  resolve: {
    test: function() {
      console.log('admin.link1 called resolve');
      return;
    }
  },
  views: {
    // instead of this// 'navigation': {// we have to use absolute name with the @ at the end'navigation@': {
      template: '<div>admin navigation</div>'
    },
    // this is searched in parent view// 'content': {// this is targting the root'content@': {
      template: '<div>admin link1</div>'
    }
  }
})

The point is hidden in the absolut view naming, an extract:

Behind the scenes, every view gets assigned an absolute name that follows a scheme of viewname@statename, where viewname is the name used in the view directive and state name is the state's absolute name, e.g. contact.item. You can also choose to write your view names in the absolute syntax.

The working example(s) here or other here

Please, try to read this answer, where I tried deeply describe what is the view naming about.(search for a last section: EXTEND: to give THE answer to a comment)

Post a Comment for "Child Route Does Not Trigger"