marklagendijk / ui-router.stateHelper

A helper module for AngularUI Router, which allows you to define your states as an object tree.
MIT License
235 stars 40 forks source link

Uncaught Error #30

Open rosostolato opened 6 years ago

rosostolato commented 6 years ago

this is my code:

stateHelperProvider

        .state({
            name: 'assets',
            url: '/assets',
            templateUrl: 'app/assets/assets.html',
            children: [
                {
                    name: 'monitoring',
                    url: '/monitoring',
                    templateUrl: 'app/assets/assetsMonitoring/assetsMonitoring.html',
                    controller: 'assetsMonitoringCtrl',
                    controllerAs: 'vm'
                },
                {
                    name: 'report',
                    url: '/report?{view:string}',
                    templateUrl: 'app/assets/assetsReport/assetsReport.html',
                    controller: 'assetsReportCtrl',
                    controllerAs: 'vm',
                    params: { view: { dynamic: true } }
                },
                {
                    name: 'manager',
                    url: '/manager',
                    templateUrl: 'app/assets/assetsManager/assetsManager.html',
                    controller: 'assetsManagerCtrl',
                    controllerAs: 'vm'
                }
            ]
        });

and this is what angular says:

Failed to instantiate module app due to: Error: States that specify the 'parent:' property should not have a '.' in their name (assets.monitoring)

I resolved the problem using { keepOriginalNames: true }, but I have to use "manager" instead of "assets.manager" in ui-sref tag and it's causing me problems with other states that has the same child name, which is the case of "manager" state.

What do I do?

stereokai commented 6 years ago

Did you solve this?

rosostolato commented 6 years ago

No, I gave up and stopped using it

stereokai commented 6 years ago

I have found what the problem is.

In this block (line 43), add delete state.parent;

            if (!options.keepOriginalNames) {
                fixStateName(state);
                delete state.parent;
            }
stereokai commented 6 years ago

@davidzwa Well, that's up to @marklagendijk, the repo owner :)