angular js ui router 动态菜单

 使用ui-router做动态路由

//controller
app.controller('DynamicCtrl', function($scope, $stateParams) {
    $scope.include = 'tpl/'+$stateParams.code +"";
});

  

//config ui-router
$stateProvider
.state('app.menu',{
      url:'/menu/:code',
      controller:'DynamicCtrl',
      //template: '
' templateUrl:'tpl/menuloader.html' });

 

 menuloader.html

 menu

 

 

menu

 另外可以参考这里的回答

 

http://stackoverflow.com/questions/17157365/how-do-i-dynamically-load-a-template-based-on-parameters-in-a-route-registered-w

你可能感兴趣的:(angularjs)