3

I am using angular and sails to build a web app, in which each user have their own them so to display their public profile I have to use different templates. I am using ui-router and if I can pass id passed to the route url to templateUrl field I can solve this problem easily, so is there a way to do that ??

app.config(function($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise('/');
  $stateProvider
    .state('profile', {
      abstract: true,
      url: '',
      templateUrl: domain + "/profile/master",
      controller: 'profileController'
    })
    .state('profile.user', {
      url: '/user/:id',
      templateUrl: domain + '/angular/profile/:id',
      controller: 'privateProfileController'
    });
});

4
  • please refer resolve in uri routing Commented Jan 11, 2016 at 12:58
  • resolve: { data : function () { return data; } } Commented Jan 11, 2016 at 13:00
  • Check Angular UI Router - Dynamic TemplateURL Commented Jan 11, 2016 at 13:06
  • ok .. let me look into it Commented Jan 11, 2016 at 13:11

1 Answer 1

3

source link

.state('contacts.detail', {
  url: '/{contactId}',
  views: {
    'menu': {
        templateUrl:
                 function (stateParams){
                    return '/partials/contacts.detail' + stateParams.contactId + '.html';
            }
    }
  }
})
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.