1

I have the following arrangement:

$stateProvider.state('home', {
        url: '/',
        template: ''
    })

    .state('profile', {
        url: '/profile/view',
        templateUrl: 'static/templates/profile.tpl.html'
    })

    .state('profile.view', {
        url: '',
        templateUrl: 'static/templates/profile-view.tpl.html',
        controller: 'profileController',
        controllerAs: 'pc'
    })

    .state('profile.edit', {
        url: '/edit',
        templateUrl: 'static/templates/profile-edit.tpl.html',
        controller: 'editProfileController',
        controllerAs: 'editCtrl'
    })
    ;

What I intend to do is - I have some common partial content between the profile.view and the profile.edit states.

The common part is supposed inside the profile state. But the current arrangement is failing and /profile/view DOES NOT render any of the partials.

No errors reported to console.

Edit: Here is profile.tpl.html

<div flex flex-gt-sm="50" flex-offset-gt-sm="25" layout="row" layout-align="center">
    <div ui-view>
    </div>
</div>

Edit 2:

After adding abstract: true the profile.view state started working fine. But profile.edit state keeps redirecting to /. Sort of following the .otherwise('/') rule

3
  • are you trying to load view and edit inside another ui-view which is in profile.tpl.html? Commented Mar 28, 2016 at 17:04
  • Or asked more directly, does your template for the "profile" state include a ui-view directive? It's required b/c the "view" and "edit" states are child states of "profile". Commented Mar 28, 2016 at 17:06
  • yes it does have a ui-view, I've updated the question Commented Mar 28, 2016 at 17:46

1 Answer 1

1

I'll answer my own question:

All I was missing was abstract: true in the profile state

Edit:

following things completely solved it for me:

  1. abstract: true in profile state
  2. url: '/profile' in profile state
  3. url: '/view' in profile.view state
  4. url: '/edit' in profile.edit state
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.