ui-路由器状态子级和解析器

ui-router State Children and Resolvers

我有一个父抽象状态,它有一个从服务器获取数据的解析器。

然后根据 ui-routers 解析器继承的性质,我可以访问子状态控制器中的已解析数据。

....controller('bla', function(resolvedData){....

一切都运行良好,但我正在应用程序中实现一项功能,该功能需要更改部分已解析数据并将其反映在整个应用程序中。

我假设解析的数据不是对一个对象的引用,而是服务正确返回的内容的副本?意思是,如果在父抽象控制器中我更改了已解析数据的一部分,它将不会反映在子状态中,因为它们会查看来自数据服务的已解析数据的原始副本。

实际上,在测试之后 ui-router 解析器似乎确实将对已解析数据的更改传递给子状态,此外,如果我在同级状态中更改已解析数据,则更改会反映在另一个同级状态中.

我正试图找到它在 ui-router 代码中的确切位置。 https://github.com/angular-ui/ui-router/blob/master/src/resolve.js

I'm assuming that the resolved data is not a reference to one object but it is a copy of what the service returned correct?

。 UI-路由器传递返回的内容。如果它是参考,它将被所有消费者共享。

检查代码 (根本没有提到克隆 - 只是传递已解决的内容) - state.js line 455

 /**

 * ....

 * @param {object=} stateConfig.resolve
 * <a id='resolve'></a>
 *
 * An optional map&lt;string, function&gt; of dependencies which
 *   should be injected into the controller. If any of these dependencies are promises, 
 *   the router will wait for them all to be resolved before the controller is instantiated.
 *   If all the promises are resolved successfully, the $stateChangeSuccess event is fired
 *   and the values of the resolved promises are injected into any controllers that reference them.
 *   If any  of the promises are rejected the $stateChangeError event is fired.

 * ... */