I have an abstract parent view that is meant to share a controller with its nested views, before I have a main controller that is the principal of my app
.state('main', {
abstract: true,
url: '/',
templateUrl: 'app/templates/main.html',
controller: 'mainController'
})
.state('main.edit', {
abstract: true,
url: '/edit',
templateUrl: 'app/templates/edit.html',
controller: 'editController'
})
.state('main.edit.details', {
url: '/details',
templateUrl: 'app/templates/editDetailsView.html',
controller: 'editDetailsController'
})
.state('main.edit.info', {
url: '/info',
templateUrl: 'app/templates/editInfoView.html',
controller: 'editInfoController'
})
The routing works as expected, before I set de controller, I have the parent controller of the module that would be edit controller and every controller of each view
The error:
"Error: [ng:areq] Argument 'editController' is not a function, got undefined
http://errors.angularjs.org/1.5.7/ng/areq?p0=editController&p1=not%20aNaNunction%2C%20got%20undefined
minErr/<@http://localhost:3000/js/libs.min.js:5:4923
assertArg@http://localhost:3000/js/libs.min.js:5:19120
assertArgFn@http://localhost:3000/js/libs.min.js:5:19322
$ControllerProvider/this.$get</<@http://localhost:3000/js/libs.min.js:7:31336
z/<.compile/<@http://localhost:3000/js/libs.min.js:15:2556
bind/<@http://localhost:3000/js/libs.min.js:5:12865
invokeLinkFn@http://localhost:3000/js/libs.min.js:7:22121
nodeLinkFn@http://localhost:3000/js/libs.min.js:7:4193
compositeLinkFn@http://localhost:3000/js/libs.min.js:6:26125
compile/<@http://localhost:3000/js/libs.min.js:6:24834
compilationGenerator/<@http://localhost:3000/js/libs.min.js:6:31172
l@http://localhost:3000/js/libs.min.js:15:1755
y/l.compile/<@http://localhost:3000/js/libs.min.js:15:2183
bind/<@http://localhost:3000/js/libs.min.js:5:12865
invokeLinkFn@http://localhost:3000/js/libs.min.js:7:22121
nodeLinkFn@http://localhost:3000/js/libs.min.js:7:4193
compositeLinkFn@http://localhost:3000/js/libs.min.js:6:26125
compile/<@http://localhost:3000/js/libs.min.js:6:24834
z/<.compile/<@http://localhost:3000/js/libs.min.js:15:2764
bind/<@http://localhost:3000/js/libs.min.js:5:12865
invokeLinkFn@http://localhost:3000/js/libs.min.js:7:22121
nodeLinkFn@http://localhost:3000/js/libs.min.js:7:4193
compositeLinkFn@http://localhost:3000/js/libs.min.js:6:26125
compile/<@http://localhost:3000/js/libs.min.js:6:24834
compilationGenerator/<@http://localhost:3000/js/libs.min.js:6:31172
l@http://localhost:3000/js/libs.min.js:15:1755
y/l.compile/</<@http://localhost:3000/js/libs.min.js:15:2175
$RootScopeProvider/this.$get</Scope.prototype.$broadcast@http://localhost:3000/js/libs.min.js:9:24515
v/y.transitionTo/y.transition<@http://localhost:3000/js/libs.min.js:14:29498
processQueue@http://localhost:3000/js/libs.min.js:9:8733
scheduleProcessQueue/<@http://localhost:3000/js/libs.min.js:9:9000
$RootScopeProvider/this.$get</Scope.prototype.$eval@http://localhost:3000/js/libs.min.js:9:22223
$RootScopeProvider/this.$get</Scope.prototype.$digest@http://localhost:3000/js/libs.min.js:9:19908
$RootScopeProvider/this.$get</Scope.prototype.$apply@http://localhost:3000/js/libs.min.js:9:22650
done@http://localhost:3000/js/libs.min.js:8:7950
completeRequest@http://localhost:3000/js/libs.min.js:8:11757
createHttpBackend/</xhr.onload@http://localhost:3000/js/libs.min.js:8:12689
"
If I erase the editController, it works well, but what can I do if I need the shared controller of my views, other way it works if i set a the parent controller like this
.state('main.edit', {
abstract: true,
url: '/edit',
templateUrl: 'app/templates/edit.html',
controller: function($scope){
console.log('edit parent controller');
}
not the idea.