Directing the user to a child state when they are transitioning to its parent state using UI-Router

前端 未结 9 706
忘掉有多难
忘掉有多难 2020-11-30 19:06

Consider the following:

.state(\'manager.staffList\', {url:\'^/staff?alpha\', templateUrl: \'views/staff.list.html\', data:{activeMenu: \'staff\'}, controlle         


        
9条回答
  •  醉酒成梦
    2020-11-30 19:41

    For setting default child view , check this example . On clicking Route 1 load default state route1.list

    // For any unmatched url, send to /route1
    $stateProvider
      .state('route1', {
          url: "/route1",
          abstract:true ,
          templateUrl: "route1.html"
      })
      .state('route1.list', {
          url: '',
          templateUrl: "route1.list.html",
          controller: function($scope){
            $scope.items = ["A", "List", "Of", "Items"];
          }
      })
      .state('route1.desc', {
          url: "/desc",
          templateUrl: "route1.desc.html",
          controller: function($scope){
            $scope.items = [];
          }
      })
      .state('route2', {
        url: "/route2",
        templateUrl: "route2.html"
      })
      .state('route2.list', {
        url: "/list",
        templateUrl: "route2.list.html",
        controller: function($scope){
          $scope.things = ["A", "Set", "Of", "Things"];
        }
      })
    

提交回复
热议问题