Okay
  Public Ticket #1089687
Route takes wrong template
Closed

Comments

  •  2
    Phillip started the conversation

    Hi again

    I have tried following, but when I go to /app/tasks/1 for example, it still takes the templateURL from the state tasks, instead of tasks.task. I have done excactly as you have done other places in the Route. Do you know why this is happening? If I remove "parent" and set the full url, it works perfect, but this way doesn't work?
    No errors in the console.

        //Tasks
        .state('tasks', {
          url: '/app/{path:afleveringer|tasks}',
          templateUrl: 'app/pages/tasks/tasks.html',
          controller: 'TasksController',
          controllerAs: 'tasks'
        })
        //Single Task
        .state('tasks.task', {
          url: '/:taskID',
          templateUrl: 'app/pages/tasks/task.html',
          controller: 'TaskController',
          controllerAs: 'tasks',
          parent: 'tasks',
          specialClass: 'force-header-sm header-sm'
        })

  •  9
    Matej replied

    Hey if you want to use route states in that way your main parent state should contain template just with this content "<div ui-view></div>". So I'm suggesting this:

    .state('tasks', {
       url: '/app/{path:afleveringer|tasks}',
       template: '<div ui-view=""></div>'
    })
    .state('tasks.list', {
       url: '/list',
       templateUrl: 'app/pages/tasks/tasks.html',
       controller: 'TasksController',
       controllerAs: 'ctrl',
       parent: tasks
    })
    .state('tasks.task', {
       url: '/:taskID',
       templateUrl: 'app/pages/tasks/task.html',
       controller: 'TaskController',
       controllerAs: 'ctrl',
       parent: tasks
    })
    

    Best regards,
    Matej Drlicka