2

I have one state in my ui-router config:

state("objects",
  url: "/:type/"
)

And I need render different templates based on :type params. For example, when user trying access /buy, I need render template /views/objects/buy.html, when /rent/views/objects/rent.html.

What can help me?

1 Answer 1

1

If I've understood you correctly. For example, if you have base url objects Your state will be:

.state('objects.rent') {
    url: "/rent",
    data: '{name: 'rent'},
    views: {
        // for one or multiple views
       'rentView': {templateUrl: '/views/objects/rent.html'}
    } 
}

// If you need to get something or initialize:
    $rootScope.$on('$stateChangeSuccess',
      function(event, toState, toParams, fromState, fromParams){
         if ($rootScope.$state.current.data !== undefined && $rootScope.$state.current.data.name !== undefined && $rootScope.$state.current.data.name === 'rent') {
           // doSomething
         } 
    });
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.