Basilin Joe
Basilin Joe

Reputation: 702

Angular passing parameters through templateUrl in ui-router

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'
    });
});

Upvotes: 3

Views: 4144

Answers (1)

Henry Zou
Henry Zou

Reputation: 1917

source link

.state('contacts.detail', {
  url: '/{contactId}',
  views: {
    'menu': {
        templateUrl:
                 function (stateParams){
                    return '/partials/contacts.detail' + stateParams.contactId + '.html';
            }
    }
  }
})

Upvotes: 3

Related Questions