Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用这种技术来加载数据。所以我创建了以下解析函数:
NoteController.resolve = { note: function($routeParams, Note) { return Note.get($routeParams.key); } }
问题是$routeParams.key在函数执行undefined的那一刻。resolve是否正确/错误?我该如何解决?
$routeParams.key
undefined
resolve
你需要$route.current.params.key改用。$routeParams仅在更改路线后更新。所以你的代码应该看起来像这样:
$route.current.params.key
$routeParams
NoteController.resolve = { note: function($route, Note) { return Note.get($route.current.params.key); } }