0
    .state('app.match.indicator.speciality',{
      url: '/speciality/:jobId?',
      views: {
        'sidebar@app.match.indicator':{
          templateUrl: ENVApp + '/views/match/match.roleProfileSideBar.html?' + cacheVersion,
        },
        'createRoles@app.match.indicator': {
          templateUrl: ENVApp + '/views/match/match.page2.html?' + cacheVersion
        }
      },
      controller: 'RoleProfileCreateSpecialtyController'
    })

That's what I have as a state definition, however my RoleProfileCreateSpecialtyController doesn't get loaded for some reason. I know this because I threw an alert in there that never happens.

What am I doing wrong?

This also fails:

    .state('app.match.indicator.speciality',{
      url: '/speciality/:jobId?',
      views: {
        'sidebar@app.match.indicator':{
          templateUrl: ENVApp + '/views/match/match.roleProfileSideBar.html?' + cacheVersion,
        },
        'createRoles@app.match.indicator': {
          templateUrl: ENVApp + '/views/match/match.page2.html?' + cacheVersion
        }
      },
      // controller: 'RoleProfileCreateSpecialityController'
      controller: function() {
        alert('fd')
      }
    })
Shamoon
  • 41,293
  • 91
  • 306
  • 570

1 Answers1

2

When defining multiple views in a state, you cannot define a single controller (see https://stackoverflow.com/a/33139917/3153169 for reference).

To fix this, you can just define the controller for the multiple views:

.state('app.match.indicator.speciality',{
    url: '/speciality/:jobId?',
    views: {
        'sidebar@app.match.indicator':{
            templateUrl: ENVApp + '/views/match/match.roleProfileSideBar.html?' + cacheVersion,
            controller: 'RoleProfileCreateSpecialtyController'
        },
        'createRoles@app.match.indicator': {
            templateUrl: ENVApp + '/views/match/match.page2.html?' + cacheVersion,
            controller: 'RoleProfileCreateSpecialtyController'
        }
    }
})
Community
  • 1
  • 1
devqon
  • 13,818
  • 2
  • 30
  • 45
  • As an addendum for the OP : read this link in the answer link by devqon : http://stackoverflow.com/q/29107012/1679310. You will probably need it. – Walfrat Dec 08 '16 at 16:11