Angular passing parameters through templateUrl in ui-router

 ̄綄美尐妖づ 提交于 2020-02-03 09:40:12

问题


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

回答1:


source link

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


来源:https://stackoverflow.com/questions/34722102/angular-passing-parameters-through-templateurl-in-ui-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!