定义& # 39;父母# 39;从Angular Ui-Router的参数中获取value

Define 'parent' value from param in Angular Ui-Router

本文关键字:参数 获取 value 父母 定义 Angular Ui-Router      更新时间:2023-09-26

嗯,我有这样的情况:

$stateProvider
.state("main", { abtract: true, url:"/main",
  views: {
   "viewA": {
     templateUrl:"main.html"
   }
 }
})
.state("other", {
  parent: ':foo', // Want here the foo param too (:
  //url: '/:foo', // Here it takes de foo param
  views: {
   "viewB@main": {
    templateUrl:"hello.html"
   }
  },
  controller: function($stateParams, $scope, $state) {
   var foo = $stateParams.foo;
  }
})

我这样命名它:

<button ui-sref="other({foo: 'main'})">Hello World</button>

有可能在'parent'属性中有'foo'参数,就像它是'url'参数一样?

它是可能有'foo'参数在'父'属性,就像它是'url'参数?

不,可能。

状态定义在使用之前必须完全注册。(即使使用deferIntercept(defer)惰性加载)

url参数的求值太晚了…