1

I got some err when i try to create external module, i think that is something wrong with my nested state in nested.js

The err said:Error: State 'admin.quyensudung' has a 'views' object. It cannot also have "view properties" at the state level. Move the following properties into a view (in the 'views' object): controller

Please help me fix this bug and tell me the reason i got this bug thank too much

app.js:

var app = angular.module('app', [
  'ui.router',
  'ngCookies',
  'quyensudung',
])
.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/admin');

$stateProvider

    .state('admin', {
        url: '/admin',
        templateUrl: 'admin/home/index.html'
}])

nested.js

var quyensudung = angular.module('quyensudung', [])

.config(['$stateProvider', function($stateProvider){
    $stateProvider
        .state('admin.quyensudung', {
            url: '/quyensudung',
            views: {
                "container@": {
                    templateUrl: 'admin/quyensudung/index.html'
                },
            },
            controller: 'quyensudungController',        
        })
}])

1 Answer 1

2

Error: State 'admin.quyensudung' has a 'views' object. It cannot also have "view properties" at the state level. Move the following properties into a view

Just move controller: 'quyensudungController', into views -> "container@"

Instead:

.state('admin.quyensudung', {
        url: '/quyensudung',
        views: {
            "container@": {
                templateUrl: 'admin/quyensudung/index.html'
            },
        },
        controller: 'quyensudungController',        
    })

Should be:

.state('admin.quyensudung', {
        url: '/quyensudung',
        views: {
            "container@": {
                templateUrl: 'admin/quyensudung/index.html',
                controller: 'quyensudungController'
            },
        }     
    })

Ref: Nested-States-and-Nested-Views

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

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.