0

I'm using angular ui router to handle state transitions, and I have a state that I can't seem to properly resolve.

The state is:

.state('organization.program.editor', {
    url: "/editor/{contentId:[0-9]{1,8}}/{workflowStateId:[0,9]{1,8}}/{projectId:[0,9]{1,8}}",
    templateUrl: "editor-editor",
    controller: 'EditorController as vm',
    resolve: {
        editorModel: ['$stateParams', 'editorService', 'orgService',
            function ($stateParams, editorService, orgService) {
                debugger;
                //edited for brevity
                return null;

            }]
    },
    params: { contentId: {}, orgId: {}, programId: {},  
              workflowStateId: { value: '-1' }, projectId: { value: '-1' } }
        })

If I navigate to /editor/2445, the transition is accepted and it successfully navigates, and my optional parameters are their defaults, -1 and -1.

However, if I try /editor/2445/1, or /editor/2445/1/1, it does not recognize the state.

What am I missing?

2
  • Do you have any 'organization.program.editor' child state? for example 'organization.program.editor.otherState'.. Commented Dec 4, 2014 at 16:22
  • @DaniCE, no, that's as low as it goes at the moment. Commented Dec 4, 2014 at 16:25

1 Answer 1

1

Ok, so I solved this. The problem is the params definition:

params: { contentId: {}, orgId: {}, programId: {},  
          workflowStateId: { value: '-1' }, projectId: { value: '-1' } }

Since I'm using numeric constraints in the url like so: editor/{contentId:[0-9]{1,8}}/{workflowStateId:[0,9]{1,8}}/{projectId:[0,9]{1,8}}, there are two violations in my param defaults.

First, [0-9]{1,8} will only match numeric values. Second, it will only match positive numeric values.

So, the '-1' value provided will never match when applied. It needs to be a number, and 0 or greater.

Hope it helps someone in the future.

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.