AngularJs UI router - one state with multiple URLs

前端 未结 5 926
醉话见心
醉话见心 2020-12-28 13:58

I have a request to add in another URL parameter that directs to a state that I already have set up. For efficiency purposes, I\'m trying to see if I can add multiple URLs t

5条回答
  •  悲&欢浪女
    2020-12-28 14:44

    you can used when() function

    .state('site.link1',
      {
        url: '/link1',
        templateUrl: '/views/link1.html',
        controller: 'link1Ctrl'
      })
    

    then on root config

    angular.module('myApp', [...])
       .config(function ($urlRouterProvider) {
           $urlRouterProvider.when(/newlink/, ['$state','$match', function ($state, $match) {
               $state.go('site.link1');
           }]);
        });
    

提交回复
热议问题