【发布时间】:2017-05-30 06:54:36
【问题描述】:
我正在将我的应用程序迁移到 ui-router 1.0.0 并且我遇到了嵌套状态的问题,当 onEnter $transitions 钩子触发多次时,该状态有多少父级(即嵌套的深度),无论我是否在我的钩子中过滤状态。这是预期的还是错误?
$stateProvider
.state("root", {
url: "/"
})
.state("root.child", {
url: "/child"
})
.state("root.child.child", {
url: "/child",
data: {
foo: "bar"
}
});
$transitions.onEnter(
{to: state => state.data && state.data.foo === "bar"},
transition =>
console.log(`on enter triggered`, transition.from(), transition.to())
);
$state.go("root.child.child");
在这个例子中,钩子被触发了 3 次。
这是fiddle。
【问题讨论】:
标签: javascript angularjs angular-ui-router