• <legend id='pod9e'><style id='pod9e'><dir id='pod9e'><q id='pod9e'></q></dir></style></legend>

    1. <i id='pod9e'><tr id='pod9e'><dt id='pod9e'><q id='pod9e'><span id='pod9e'><b id='pod9e'><form id='pod9e'><ins id='pod9e'></ins><ul id='pod9e'></ul><sub id='pod9e'></sub></form><legend id='pod9e'></legend><bdo id='pod9e'><pre id='pod9e'><center id='pod9e'></center></pre></bdo></b><th id='pod9e'></th></span></q></dt></tr></i><div id='pod9e'><tfoot id='pod9e'></tfoot><dl id='pod9e'><fieldset id='pod9e'></fieldset></dl></div>

      <tfoot id='pod9e'></tfoot>
        • <bdo id='pod9e'></bdo><ul id='pod9e'></ul>

        <small id='pod9e'></small><noframes id='pod9e'>

      1. 如何使 Angular ui-router 的父状态在状态更改时始终执行控制器代码?

        How to make angular ui-router#39;s parent state always execute controller code when state changes?(如何使 Angular ui-router 的父状态在状态更改时始终执行控制器代码?)
          <bdo id='zFBuW'></bdo><ul id='zFBuW'></ul>
            <tbody id='zFBuW'></tbody>

          <i id='zFBuW'><tr id='zFBuW'><dt id='zFBuW'><q id='zFBuW'><span id='zFBuW'><b id='zFBuW'><form id='zFBuW'><ins id='zFBuW'></ins><ul id='zFBuW'></ul><sub id='zFBuW'></sub></form><legend id='zFBuW'></legend><bdo id='zFBuW'><pre id='zFBuW'><center id='zFBuW'></center></pre></bdo></b><th id='zFBuW'></th></span></q></dt></tr></i><div id='zFBuW'><tfoot id='zFBuW'></tfoot><dl id='zFBuW'><fieldset id='zFBuW'></fieldset></dl></div>

            1. <legend id='zFBuW'><style id='zFBuW'><dir id='zFBuW'><q id='zFBuW'></q></dir></style></legend>

              1. <small id='zFBuW'></small><noframes id='zFBuW'>

                • <tfoot id='zFBuW'></tfoot>

                  本文介绍了如何使 Angular ui-router 的父状态在状态更改时始终执行控制器代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我们在 $stateProvider 中定义了一个父子关系,如下所示:

                  Let's say we have a parent-child relationship defined in our $stateProvider as follows:

                      .state('myProfile', {
                          url: "/my/profile",
                          templateUrl: 'my/profile.html',
                          controller: 'MyProfileController'
                      }).state('myProfile.edit', {
                          url: "/edit",
                          templateUrl: 'my/profile.edit.html',
                          controller: 'EditMyProfileController'
                      });
                  

                  这里的想法是父 myProfile 状态是不可编辑的,但子 myProfile.edit 状态是编辑配置文件的实际表单.让我们忽略个人资料页面是否应该这样工作 - 我只是在玩弄东西和学习.

                  The idea here is that the parent myProfile state is non-editable, but the child myProfile.edit state is the actual form to edit the profile. Let's ignore if this is how a profile page should work - I'm just playing around with things and learning.

                  当用户提交表单时,我使用 $state 对象返回到父页面:

                  When a user submits the form, I use the $state object to go back to the parent page:

                  $scope.save = function() {
                      userResource.update($scope.user, function() {
                          SessionService.refresh();
                  
                          $state.go('myProfile'); // also tried with reload: true as well
                      });
                  }
                  

                  在用户保存配置文件数据后 - 正确保存 - 除非我按 F5 并刷新浏览器,否则父视图不会更新.

                  After the user saves the profile data - and it is getting saved properly - the parent's view does not get updated unless I hit F5 and refresh the browser.

                  我注意到的一件事是,如果我将子 myProfile.edit 状态设置为父状态,而不是 myProfile 状态的子状态,则此问题实际上会出现离开了,事情就按预期运行了(尽管这样的布局看起来很糟糕).

                  One thing I have noticed is that if I make the child myProfile.edit state into a parent itself and not a child of the myProfile state, this problem actually goes away and things behave as expected (albeit, the layout looks bad like this).

                  似乎 UI Router 可能正在缓存父级的结果,不知道模型中的事情发生了变化并且需要重新运行控制器?

                  It seems that UI Router is maybe caching the result of the parent, unsuspecting that things have changed in the model and that it needs to rerun the controller?

                  如何在保持父 myProfile 页面始终执行其控制器以重新加载其数据的同时保持我的父子关系?基本上,我希望在使用 $state 或单击指向 myProfile 的链接时发生这种情况.我该怎么做?

                  How can I keep my parent-child relationship while still having the parent myProfile page always execute its controller to reload its data? Basically, I want this to happen whenever $state is used or when a link is clicked that directs to myProfile. How can I do that?

                  如果我不能按照我的要求做,那么我知道我可以设置一堆子状态并让它们按预期工作......但是,我如何为父级设置默认子状态?例如,假设我希望 myProfile.edit 成为 myProfile 的默认子状态 - 我该怎么做?

                  And if I cannot do what I ask, then I am aware that I can setup a bunch of child states and have them work as intended... however, how can I set the default child state for the parent? For example, let's say I want myProfile.edit to be the default child state of myProfile - how can I do that?

                  谢谢!

                  推荐答案

                  要在从子状态导航到父状态时强制重新加载父状态,您可以使用以下两种方式.纯js或者指令属性.

                  To force a parent state to reload when navigate to him from a child state you can use both ways below. Pure js or a directive attribute.

                  <a ui-sref="myProfile" ui-sref-opts="{ reload: true }">Back to My Profile</a>
                  

                  $state.go('myProfile', null, { reload: true });
                  

                  这篇关于如何使 Angular ui-router 的父状态在状态更改时始终执行控制器代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))
                  • <bdo id='UAAG7'></bdo><ul id='UAAG7'></ul>

                      <tfoot id='UAAG7'></tfoot>
                      1. <legend id='UAAG7'><style id='UAAG7'><dir id='UAAG7'><q id='UAAG7'></q></dir></style></legend>

                      2. <small id='UAAG7'></small><noframes id='UAAG7'>

                        <i id='UAAG7'><tr id='UAAG7'><dt id='UAAG7'><q id='UAAG7'><span id='UAAG7'><b id='UAAG7'><form id='UAAG7'><ins id='UAAG7'></ins><ul id='UAAG7'></ul><sub id='UAAG7'></sub></form><legend id='UAAG7'></legend><bdo id='UAAG7'><pre id='UAAG7'><center id='UAAG7'></center></pre></bdo></b><th id='UAAG7'></th></span></q></dt></tr></i><div id='UAAG7'><tfoot id='UAAG7'></tfoot><dl id='UAAG7'><fieldset id='UAAG7'></fieldset></dl></div>
                              <tbody id='UAAG7'></tbody>