官术网_书友最值得收藏!

  • Angular Router
  • Victor Savkin
  • 241字
  • 2021-07-09 19:20:32

Summary

Let's look at all the operations of the Angular router one more time:

When the browser is loading /inbox/33/messages/44(popup:compose), the router will do the following. First, it will apply redirects. In this example, none of them will be applied, and the URL will stay as is. Then the router will use this URL to construct a new router state:

Next, the router will instantiate the conversation and message components:

Now, let's say the message component has the following link in its template:

<a [routerLink]="[{outlets: {popup: ['message', this.id]}}]">Edit</a>

The router link directive will take the array and will set the href attribute to

/inbox/33/messages/44(popup:message/44). Now, the user triggers a navigation by clicking on the link. The router will take the constructed URL and start the process all over again: it will find that the conversation and message components are already in place. So no work is needed there. But it will create an instance of PopupMessageCmp and place it into the popup outlet. Once this is done, the router will update the location property with the new URL.

That was intense-a lot of information! But we learned quite a few things. We learned about the core operations of the Angular router: applying redirects, state recognition, running guards and resolving data, component activation, and navigation. Finally, we looked at an e2e example showing the router in action.

In the rest of this book we will discuss the same operations one more time in much greater depth.

主站蜘蛛池模板: 凌海市| 镇雄县| 静乐县| 永昌县| 新竹市| 新乐市| 民丰县| 五峰| 尼玛县| 阜平县| 新宾| 长沙县| 寿光市| 清镇市| 玉门市| 当雄县| 全州县| 霍山县| 兰州市| 柘城县| 盐城市| 扬中市| 平利县| 新化县| 抚宁县| 盱眙县| 逊克县| 托克托县| 永年县| 陈巴尔虎旗| 高阳县| 定远县| 团风县| 祁连县| 萝北县| 高安市| 美姑县| 香港| 富蕴县| 莱阳市| 博罗县|