{"id":471293,"date":"2025-08-20T03:00:39","date_gmt":"2025-08-20T03:00:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=471293"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=471293","title":{"rendered":"<span>Angular Router \u0434\u043b\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445: \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0433\u0430\u0439\u0434 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u0441\u0430\u0439\u0442-\u0432\u0438\u0437\u0438\u0442\u043a\u0443 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Angular. \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c <strong>\u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/strong>, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u00ab\u041e \u043d\u0430\u0441\u00bb \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441 \u0442\u043e\u0432\u0430\u0440\u0430\u043c\u0438. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438<\/p>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0430\u0439\u0442\u0430\u0445 \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0438\u043a\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u043e\u0432\u0443\u044e HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u041d\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <strong>SPA (Single Page Applications)<\/strong> \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u043d\u0430\u0447\u0435 \u2014 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <strong>Angular Router<\/strong>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b (\u043a\u0430\u043a\u043e\u0439 URL \u2192 \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442);<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 query-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Guard\u2019\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e (lazy loading).<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e <strong>Router \u2014 \u044d\u0442\u043e \u0441\u0435\u0440\u0434\u0446\u0435 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0432 Angular-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445<\/strong>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043f\u043e\u0439\u043c\u0451\u0442\u0435, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u00bb<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c Angular Router \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e: \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u0442\u0440\u0435\u043c\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0432\u0435\u0449\u0435\u0439 \u0432\u0440\u043e\u0434\u0435 Guard\u2019\u043e\u0432 \u0438 \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0412\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0436\u0438\u0432\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/p>\n<h2>\u041c\u0438\u043d\u0438-\u043f\u0440\u043e\u0435\u043a\u0442: Pizza Router App \ud83c\udf55<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 Angular Router, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u0430\u0439\u0442 \u043f\u0438\u0446\u0446\u0435\u0440\u0438\u0438. \u0423 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/<\/code> \u2014 <strong>\u0413\u043b\u0430\u0432\u043d\u0430\u044f<\/strong> (\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d + \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043f\u0438\u0446\u0446\u044b),<\/p>\n<\/li>\n<li>\n<p><code>\/menu<\/code> \u2014 <strong>\u041c\u0435\u043d\u044e<\/strong> (\u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0438\u0446\u0446),<\/p>\n<\/li>\n<li>\n<p><code>\/pizza\/:id<\/code> \u2014 <strong>\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0438\u0446\u0446\u044b<\/strong> (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u043e\u0443\u0442),<\/p>\n<\/li>\n<li>\n<p><code>\/contacts<\/code> \u2014 <strong>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e \u0445\u043e\u0434\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c:<\/p>\n<ul>\n<li>\n<p><strong>queryParams<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0438\u0446\u0446 \u043f\u043e \u0446\u0435\u043d\u0435),<\/p>\n<\/li>\n<li>\n<p><strong>Guard<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00ab\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u00bb),<\/p>\n<\/li>\n<li>\n<p><strong>Lazy loading<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u0438\u0446\u0446).<\/p>\n<\/li>\n<\/ul>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u0438\u0446\u0446\u0435\u0440\u0438\u0438 \ud83c\udf55<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/p>\n<pre><code class=\"bash\">ng g c components\/home ng g c components\/menu ng g c components\/pizza ng g c components\/contacts<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c.<\/p>\n<p><code>home.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h1&gt;\ud83c\udf55 \u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 Pizza Router App!&lt;\/h1&gt; &lt;p&gt;\u0417\u0434\u0435\u0441\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u043a\u0443\u0441\u043d\u0443\u044e \u043f\u0438\u0446\u0446\u0443 \u0438 \u0437\u0430\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0451 \u043e\u043d\u043b\u0430\u0439\u043d&lt;\/p&gt; &lt;a routerLink=\"\/menu\"&gt;\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043c\u0435\u043d\u044e&lt;\/a&gt;<\/code><\/pre>\n<p><code>menu.ts<\/code><\/p>\n<pre><code class=\"typescript\">import { Component } from '@angular\/core';  @Component({   selector: 'app-menu',   imports: [],   templateUrl: '.\/menu.html',   styleUrl: '.\/menu.scss' }) export class Menu {   pizzas = [     { id: 1, name: '\u041c\u0430\u0440\u0433\u0430\u0440\u0438\u0442\u0430', price: 450 },     { id: 2, name: '\u041f\u0435\u043f\u043f\u0435\u0440\u043e\u043d\u0438', price: 550 },     { id: 3, name: '\u0427\u0435\u0442\u044b\u0440\u0435 \u0441\u044b\u0440\u0430', price: 600 },   ]; }<\/code><\/pre>\n<p><code>menu.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h2&gt;\u041c\u0435\u043d\u044e \u043f\u0438\u0446\u0446&lt;\/h2&gt; &lt;ul&gt;   @for (pizza of pizzas; track pizza.id) {     &lt;li&gt;       &lt;a [routerLink]=\"['\/pizza', pizza.id]\"&gt;         {{ pizza.name }} \u2014 {{ pizza.price }} \u20bd       &lt;\/a&gt;     &lt;\/li&gt;   } &lt;\/ul&gt;<\/code><\/pre>\n<p><code>pizza.ts<\/code><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <strong>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <\/strong><code><strong>id<\/strong><\/code><\/p>\n<pre><code class=\"typescript\">import {Component, inject, OnInit} from '@angular\/core'; import {ActivatedRoute, RouterLink} from '@angular\/router';  @Component({   selector: 'app-pizza',   imports: [     RouterLink   ],   templateUrl: '.\/pizza.html',   styleUrl: '.\/pizza.scss' }) export class Pizza implements OnInit {   private readonly route = inject(ActivatedRoute);   pizzaId: string | null = null;    ngOnInit() {     this.pizzaId = this.route.snapshot.paramMap.get('id');   } } <\/code><\/pre>\n<p><code>pizza.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h2&gt;\u0412\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043f\u0438\u0446\u0446\u0443 \u2116{{ pizzaId }}&lt;\/h2&gt; &lt;p&gt;\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u0438\u0446\u0446\u0435 (\u0438\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u044b, \u0444\u043e\u0442\u043e, \u043e\u0442\u0437\u044b\u0432\u044b)&lt;\/p&gt; &lt;a routerLink=\"\/menu\"&gt;\u2b05 \u041d\u0430\u0437\u0430\u0434 \u0432 \u043c\u0435\u043d\u044e&lt;\/a&gt; <\/code><\/pre>\n<p><code>contacts.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h2&gt;\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b&lt;\/h2&gt; &lt;p&gt;\ud83d\udccd \u0410\u0434\u0440\u0435\u0441: \u0443\u043b. Angular, 42&lt;\/p&gt; &lt;p&gt;\ud83d\udcde \u0422\u0435\u043b\u0435\u0444\u043e\u043d: +7 (999) 123-45-67&lt;\/p&gt;<\/code><\/pre>\n<h3>2. \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0440\u043e\u0443\u0442\u0438\u043d\u0433<\/h3>\n<p>Angular Router \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0440\u043e\u0443\u0442\u044b<\/p>\n<pre><code class=\"typescript\">\/\/ app.routes.ts  import {Routes} from '@angular\/router'; import {Home} from '.\/components\/home\/home'; import {Menu} from '.\/components\/menu\/menu'; import {Pizza} from '.\/components\/pizza\/pizza'; import {Contacts} from '.\/components\/contacts\/contacts';  export const routes: Routes = [   {path: '', component: Home},   {path: 'menu', component: Menu},   {path: 'pizza\/:id', component: Pizza},   {path: 'contacts', component: Contacts}, ]; <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 <code>app.html<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u0438 \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"xml\">&lt;nav&gt;   &lt;a routerLink=\"\/\"&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt; |   &lt;a routerLink=\"\/menu\"&gt;\u041c\u0435\u043d\u044e&lt;\/a&gt; |   &lt;a routerLink=\"\/contacts\"&gt;\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b&lt;\/a&gt; &lt;\/nav&gt;  &lt;!-- \u0421\u044e\u0434\u0430 Angular \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 --&gt; &lt;router-outlet&gt;&lt;\/router-outlet&gt; <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 (<code>ng serve<\/code>), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043a\u043b\u0438\u043a\u0430\u0442\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \ud83c\udf89<\/p>\n<h3>3. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432<\/h3>\n<p>\u0423 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>path<\/code> \u0438 <code>component<\/code>. \u0412\u043e\u0442 \u0441\u0430\u043c\u044b\u0435 \u0432\u0430\u0436\u043d\u044b\u0435:<\/p>\n<h3>redirectTo<\/h3>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442<\/p>\n<p><code>{ path: '', redirectTo: 'menu', pathMatch: 'full' }<\/code><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u0445\u043e\u0434\u0435 \u043d\u0430 <code>\/<\/code> \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u0435\u043d\u044e<\/p>\n<h3>pathMatch<\/h3>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c.<\/p>\n<ul>\n<li>\n<p><code>full<\/code> \u2014 \u043f\u0443\u0442\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e<\/p>\n<\/li>\n<li>\n<p><code>prefix<\/code> \u2014 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0430\u0447\u0430\u043b\u0443<\/p>\n<\/li>\n<\/ul>\n<p><code>{ path: '', redirectTo: 'menu', pathMatch: 'full' }<\/code><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 <code>prefix<\/code>, \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 <code>\/pizza\/1<\/code>)<\/p>\n<h3>title<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Angular 14, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u044f\u043c\u043e \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0435<\/p>\n<p><code>{ path: 'menu', component: Menu, title: '\u041c\u0435\u043d\u044e \u043f\u0438\u0446\u0446' }<\/code><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 <code>\/menu<\/code> \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 <code>Pizza Router App - \u041c\u0435\u043d\u044e \u043f\u0438\u0446\u0446<\/code><\/p>\n<h3>children<\/h3>\n<p>\u0414\u043b\u044f <strong>\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432<\/strong>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u00ab\u041b\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u00bb:<\/p>\n<pre><code class=\"typescript\">{   path: 'profile',   component: ProfileLayout,   children: [     { path: 'orders', component: Orders },     { path: 'settings', component: Settings },   ] }<\/code><\/pre>\n<h3>canActivate<\/h3>\n<p>\u0414\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0440\u043e\u0444\u0438\u043b\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c:<\/p>\n<p><code>{ path: 'profile', component: ProfileLayout, canActivate: [AuthGuard] }<\/code><\/p>\n<h2>\u041b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (Lazy Loading) \u0432 Angular Router<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Angular \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 <strong>\u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/strong> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u2014 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0438 \u0441\u043e\u0442\u043d\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0441 \u043b\u0438\u0447\u043d\u044b\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u043c, \u0430\u0434\u043c\u0438\u043d\u043a\u043e\u0439, \u043a\u043e\u0440\u0437\u0438\u043d\u043e\u0439, \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438) \u2192 bundle \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439<\/p>\n<p>\u041a\u0430\u043a \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 Lazy Loading?<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u00ab\u0440\u0430\u0437\u0431\u0438\u0442\u044c\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0445 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b<\/strong><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u00ab\u041f\u0438\u0446\u0446\u0435\u0440\u0438\u044f\u00bb:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e <code>\u0413\u043b\u0430\u0432\u043d\u0430\u044f<\/code>, <code>\u041c\u0435\u043d\u044e<\/code>, <code>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0430 \u0432\u043e\u0442 <strong>\u0430\u0434\u043c\u0438\u043d\u043a\u0443<\/strong> (<code>\/admin<\/code>) \u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430<\/p>\n<\/li>\n<\/ul>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0440\u043e\u0443\u0442\u0438\u043d\u0433<\/p>\n<pre><code class=\"typescript\">import {Routes} from '@angular\/router'; import {Home} from '.\/components\/home\/home'; import {Menu} from '.\/components\/menu\/menu'; import {Pizza} from '.\/components\/pizza\/pizza'; import {Contacts} from '.\/components\/contacts\/contacts';  export const routes: Routes = [   {path: 'menu', component: Menu},   {path: 'pizza\/:id', component: Pizza},   {path: 'contacts', component: Contacts},   { path: '', redirectTo: 'menu', pathMatch: 'full' } ]; <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c <strong>\u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0440\u043e\u0443\u0442<\/strong> \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u043a\u0438:<\/p>\n<pre><code class=\"typescript\">export const routes: Routes = [   { path: 'menu', component: Menu },   { path: 'pizza\/:id', component: Pizza },   { path: 'contacts', component: Contacts },   { path: '', redirectTo: 'menu', pathMatch: 'full' },    \/\/ \ud83d\udc47 \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0440\u043e\u0443\u0442 \u0441\u043e standalone \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c   {     path: 'admin',     loadComponent: () =&gt;       import('.\/pages\/admin\/admin').then(m =&gt; m.Admin),   }, ];<\/code><\/pre>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u0443 \u043d\u0435\u0451 \u0435\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (<code>\/admin\/orders<\/code>, <code>\/admin\/settings<\/code>), \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <code>routes<\/code><\/p>\n<pre><code class=\"typescript\">export const routes: Routes = [   { path: 'menu', component: Menu },   { path: 'pizza\/:id', component: Pizza },   { path: 'contacts', component: Contacts },   { path: '', redirectTo: 'menu', pathMatch: 'full' },    {     path: 'admin',     loadChildren: () =&gt;       import('.\/pages\/admin\/admin.routes').then(m =&gt; m.adminRoutes),   }, ];<\/code><\/pre>\n<p>\u0410 \u0432\u043d\u0443\u0442\u0440\u0438 <code>admin.routes.ts:<\/code><\/p>\n<pre><code class=\"typescript\">import { Routes } from '@angular\/router'; import { AdminDashboard } from '.\/dashboard\/dashboard'; import { AdminOrders } from '.\/orders\/orders';  export const adminRoutes: Routes = [   { path: '', component: AdminDashboard },   { path: 'orders', component: AdminOrders }, ]; <\/code><\/pre>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c loadComponent, \u0430 \u043a\u043e\u0433\u0434\u0430 loadChildren?<\/h3>\n<ul>\n<li>\n<p><code>loadComponent<\/code> \u2014 \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f <strong>\u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/strong>, \u0442\u0438\u043f\u0430 <code>\/admin<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>loadChildren<\/code> \u2014 \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f <strong>\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0430<\/strong>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>\/admin\/orders<\/code>, <code>\/admin\/settings<\/code><\/p>\n<\/li>\n<\/ul>\n<h3>\ud83c\udfaf \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041c\u044b \u043f\u0440\u043e\u0448\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0443\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b (<code>path<\/code>, <code>component<\/code>),<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 (<code>:id<\/code>, <code>queryParams<\/code>),<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (<code>redirectTo<\/code>, <code>pathMatch<\/code>, <code>title<\/code>),<\/p>\n<\/li>\n<li>\n<p>\u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0440\u043e\u0443\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d <strong>Angular Router<\/strong> \u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 <\/p>\n<p>\u0425\u043e\u0442\u0438\u0442\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u0430\u0439\u0442-\u0432\u0438\u0437\u0438\u0442\u043a\u0443, \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0438\u043b\u0438 \u0446\u0435\u043b\u0443\u044e \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u0442\u0435\u0445 \u0437\u043d\u0430\u043d\u0438\u044f\u0445, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/938804\/\"> https:\/\/habr.com\/ru\/articles\/938804\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u0441\u0430\u0439\u0442-\u0432\u0438\u0437\u0438\u0442\u043a\u0443 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u043d\u0430 Angular. \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c <strong>\u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/strong>, \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u00ab\u041e \u043d\u0430\u0441\u00bb \u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441 \u0442\u043e\u0432\u0430\u0440\u0430\u043c\u0438. \u041b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0442\u043e \u043f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438<\/p>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0441\u0430\u0439\u0442\u0430\u0445 \u044d\u0442\u043e \u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043a\u043b\u0438\u043a\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043d\u043e\u0432\u0443\u044e HTML-\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u041d\u043e \u0432 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 <strong>SPA (Single Page Applications)<\/strong> \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u043d\u0430\u0447\u0435 \u2014 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0440\u0430\u0437, \u0430 \u0434\u0430\u043b\u044c\u0448\u0435 \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0435\u0433\u043e<\/p>\n<p>\u0418\u043c\u0435\u043d\u043d\u043e \u0437\u0430 \u044d\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 <strong>Angular Router<\/strong>. \u041e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442:<\/p>\n<ul>\n<li>\n<p>\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b (\u043a\u0430\u043a\u043e\u0439 URL \u2192 \u043a\u0430\u043a\u043e\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442);<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0431\u0435\u0437 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438 query-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432 \u0430\u0434\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Guard\u2019\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044e (lazy loading).<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e <strong>Router \u2014 \u044d\u0442\u043e \u0441\u0435\u0440\u0434\u0446\u0435 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u0432 Angular-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u0445<\/strong>. \u0415\u0441\u043b\u0438 \u0432\u044b \u0435\u0433\u043e \u043f\u043e\u0439\u043c\u0451\u0442\u0435, \u0442\u043e \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0435 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u00ab\u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u00bb<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c Angular Router \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e: \u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0441 \u0442\u0440\u0435\u043c\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438 \u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u0445 \u0432\u0435\u0449\u0435\u0439 \u0432\u0440\u043e\u0434\u0435 Guard\u2019\u043e\u0432 \u0438 \u043b\u0435\u043d\u0438\u0432\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0412\u0441\u0451 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u0436\u0438\u0432\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u0445 \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u0441\u043c\u043e\u0433\u043b\u0438 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435<\/p>\n<h2>\u041c\u0438\u043d\u0438-\u043f\u0440\u043e\u0435\u043a\u0442: Pizza Router App \ud83c\udf55<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 Angular Router, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u0430\u0439\u0442 \u043f\u0438\u0446\u0446\u0435\u0440\u0438\u0438. \u0423 \u043d\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\n<p><code>\/<\/code> \u2014 <strong>\u0413\u043b\u0430\u0432\u043d\u0430\u044f<\/strong> (\u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u044d\u043a\u0440\u0430\u043d + \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u043f\u0438\u0446\u0446\u044b),<\/p>\n<\/li>\n<li>\n<p><code>\/menu<\/code> \u2014 <strong>\u041c\u0435\u043d\u044e<\/strong> (\u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0441\u0435\u0445 \u043f\u0438\u0446\u0446),<\/p>\n<\/li>\n<li>\n<p><code>\/pizza\/:id<\/code> \u2014 <strong>\u0414\u0435\u0442\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0438\u0446\u0446\u044b<\/strong> (\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u043e\u0443\u0442),<\/p>\n<\/li>\n<li>\n<p><code>\/contacts<\/code> \u2014 <strong>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b<\/strong>.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e \u0445\u043e\u0434\u0443 \u0441\u0442\u0430\u0442\u044c\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c:<\/p>\n<ul>\n<li>\n<p><strong>queryParams<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043f\u0438\u0446\u0446 \u043f\u043e \u0446\u0435\u043d\u0435),<\/p>\n<\/li>\n<li>\n<p><strong>Guard<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00ab\u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043a\u0430\u0437\u00bb),<\/p>\n<\/li>\n<li>\n<p><strong>Lazy loading<\/strong> (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u043f\u0438\u0446\u0446).<\/p>\n<\/li>\n<\/ul>\n<h3>1. \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u0438\u0446\u0446\u0435\u0440\u0438\u0438 \ud83c\udf55<\/h3>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b:<\/p>\n<pre><code class=\"bash\">ng g c components\/home ng g c components\/menu ng g c components\/pizza ng g c components\/contacts<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c 4 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c.<\/p>\n<p><code>home.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h1&gt;\ud83c\udf55 \u0414\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c \u0432 Pizza Router App!&lt;\/h1&gt; &lt;p&gt;\u0417\u0434\u0435\u0441\u044c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u043a\u0443\u0441\u043d\u0443\u044e \u043f\u0438\u0446\u0446\u0443 \u0438 \u0437\u0430\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0451 \u043e\u043d\u043b\u0430\u0439\u043d&lt;\/p&gt; &lt;a routerLink=\"\/menu\"&gt;\u041f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u043c\u0435\u043d\u044e&lt;\/a&gt;<\/code><\/pre>\n<p><code>menu.ts<\/code><\/p>\n<pre><code class=\"typescript\">import { Component } from '@angular\/core';  @Component({   selector: 'app-menu',   imports: [],   templateUrl: '.\/menu.html',   styleUrl: '.\/menu.scss' }) export class Menu {   pizzas = [     { id: 1, name: '\u041c\u0430\u0440\u0433\u0430\u0440\u0438\u0442\u0430', price: 450 },     { id: 2, name: '\u041f\u0435\u043f\u043f\u0435\u0440\u043e\u043d\u0438', price: 550 },     { id: 3, name: '\u0427\u0435\u0442\u044b\u0440\u0435 \u0441\u044b\u0440\u0430', price: 600 },   ]; }<\/code><\/pre>\n<p><code>menu.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h2&gt;\u041c\u0435\u043d\u044e \u043f\u0438\u0446\u0446&lt;\/h2&gt; &lt;ul&gt;   @for (pizza of pizzas; track pizza.id) {     &lt;li&gt;       &lt;a [routerLink]=\"['\/pizza', pizza.id]\"&gt;         {{ pizza.name }} \u2014 {{ pizza.price }} \u20bd       &lt;\/a&gt;     &lt;\/li&gt;   } &lt;\/ul&gt;<\/code><\/pre>\n<p><code>pizza.ts<\/code><\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <strong>\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <\/strong><code><strong>id<\/strong><\/code><\/p>\n<pre><code class=\"typescript\">import {Component, inject, OnInit} from '@angular\/core'; import {ActivatedRoute, RouterLink} from '@angular\/router';  @Component({   selector: 'app-pizza',   imports: [     RouterLink   ],   templateUrl: '.\/pizza.html',   styleUrl: '.\/pizza.scss' }) export class Pizza implements OnInit {   private readonly route = inject(ActivatedRoute);   pizzaId: string | null = null;    ngOnInit() {     this.pizzaId = this.route.snapshot.paramMap.get('id');   } } <\/code><\/pre>\n<p><code>pizza.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h2&gt;\u0412\u044b \u0432\u044b\u0431\u0440\u0430\u043b\u0438 \u043f\u0438\u0446\u0446\u0443 \u2116{{ pizzaId }}&lt;\/h2&gt; &lt;p&gt;\u0417\u0434\u0435\u0441\u044c \u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0431\u044b\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u0438\u0446\u0446\u0435 (\u0438\u043d\u0433\u0440\u0435\u0434\u0438\u0435\u043d\u0442\u044b, \u0444\u043e\u0442\u043e, \u043e\u0442\u0437\u044b\u0432\u044b)&lt;\/p&gt; &lt;a routerLink=\"\/menu\"&gt;\u2b05 \u041d\u0430\u0437\u0430\u0434 \u0432 \u043c\u0435\u043d\u044e&lt;\/a&gt; <\/code><\/pre>\n<p><code>contacts.html<\/code><\/p>\n<pre><code class=\"xml\">&lt;h2&gt;\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b&lt;\/h2&gt; &lt;p&gt;\ud83d\udccd \u0410\u0434\u0440\u0435\u0441: \u0443\u043b. Angular, 42&lt;\/p&gt; &lt;p&gt;\ud83d\udcde \u0422\u0435\u043b\u0435\u0444\u043e\u043d: +7 (999) 123-45-67&lt;\/p&gt;<\/code><\/pre>\n<h3>2. \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0440\u043e\u0443\u0442\u0438\u043d\u0433<\/h3>\n<p>Angular Router \u0443\u0436\u0435 \u0432\u0441\u0442\u0440\u043e\u0435\u043d, \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0448\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448\u0438 \u0440\u043e\u0443\u0442\u044b<\/p>\n<pre><code class=\"typescript\">\/\/ app.routes.ts  import {Routes} from '@angular\/router'; import {Home} from '.\/components\/home\/home'; import {Menu} from '.\/components\/menu\/menu'; import {Pizza} from '.\/components\/pizza\/pizza'; import {Contacts} from '.\/components\/contacts\/contacts';  export const routes: Routes = [   {path: '', component: Home},   {path: 'menu', component: Menu},   {path: 'pizza\/:id', component: Pizza},   {path: 'contacts', component: Contacts}, ]; <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 <code>app.html<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u0438 \u043c\u0435\u0441\u0442\u043e, \u0433\u0434\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:<\/p>\n<pre><code class=\"xml\">&lt;nav&gt;   &lt;a routerLink=\"\/\"&gt;\u0413\u043b\u0430\u0432\u043d\u0430\u044f&lt;\/a&gt; |   &lt;a routerLink=\"\/menu\"&gt;\u041c\u0435\u043d\u044e&lt;\/a&gt; |   &lt;a routerLink=\"\/contacts\"&gt;\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b&lt;\/a&gt; &lt;\/nav&gt;  &lt;!-- \u0421\u044e\u0434\u0430 Angular \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u0442\u044c \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 --&gt; &lt;router-outlet&gt;&lt;\/router-outlet&gt; <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442 (<code>ng serve<\/code>), \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u0436\u0435 \u043a\u043b\u0438\u043a\u0430\u0442\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \ud83c\udf89<\/p>\n<h3>3. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432<\/h3>\n<p>\u0423 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e <code>path<\/code> \u0438 <code>component<\/code>. \u0412\u043e\u0442 \u0441\u0430\u043c\u044b\u0435 \u0432\u0430\u0436\u043d\u044b\u0435:<\/p>\n<h3>redirectTo<\/h3>\n<p>\u041f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u043c\u0430\u0440\u0448\u0440\u0443\u0442<\/p>\n<p><code>{ path: '', redirectTo: 'menu', pathMatch: 'full' }<\/code><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0437\u0430\u0445\u043e\u0434\u0435 \u043d\u0430 <code>\/<\/code> \u0441\u0440\u0430\u0437\u0443 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u043c\u0435\u043d\u044e<\/p>\n<h3>pathMatch<\/h3>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043f\u0443\u0442\u044c.<\/p>\n<ul>\n<li>\n<p><code>full<\/code> \u2014 \u043f\u0443\u0442\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e<\/p>\n<\/li>\n<li>\n<p><code>prefix<\/code> \u2014 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u043f\u043e \u043d\u0430\u0447\u0430\u043b\u0443<\/p>\n<\/li>\n<\/ul>\n<p><code>{ path: '', redirectTo: 'menu', pathMatch: 'full' }<\/code><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u044b \u043c\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 <code>prefix<\/code>, \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b \u0431\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u043e (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0436\u0435 \u043f\u0440\u0438 <code>\/pizza\/1<\/code>)<\/p>\n<h3>title<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 Angular 14, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0440\u044f\u043c\u043e \u0432 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0435<\/p>\n<p><code>{ path: 'menu', component: Menu, title: '\u041c\u0435\u043d\u044e \u043f\u0438\u0446\u0446' }<\/code><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u043d\u0430 <code>\/menu<\/code> \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0431\u0443\u0434\u0435\u0442 <code>Pizza Router App - \u041c\u0435\u043d\u044e \u043f\u0438\u0446\u0446<\/code><\/p>\n<h3>children<\/h3>\n<p>\u0414\u043b\u044f <strong>\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432<\/strong>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u00ab\u041b\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u00bb:<\/p>\n<pre><code class=\"typescript\">{   path: 'profile',   component: ProfileLayout,   children: [     { path: 'orders', component: Orders },     { path: 'settings', component: Settings },   ] }<\/code><\/pre>\n<h3>canActivate<\/h3>\n<p>\u0414\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0440\u043e\u0444\u0438\u043b\u044e \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c:<\/p>\n<p><code>{ path: 'profile', component: ProfileLayout, canActivate: [AuthGuard] }<\/code><\/p>\n<h2>\u041b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 (Lazy Loading) \u0432 Angular Router<\/h2>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Angular \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u0442 <strong>\u0432\u0435\u0441\u044c \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/strong> \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u2014 \u044d\u0442\u043e \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0434\u0435\u0441\u044f\u0442\u043a\u0438 \u0438 \u0441\u043e\u0442\u043d\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0441 \u043b\u0438\u0447\u043d\u044b\u043c \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u043e\u043c, \u0430\u0434\u043c\u0438\u043d\u043a\u043e\u0439, \u043a\u043e\u0440\u0437\u0438\u043d\u043e\u0439, \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438) \u2192 bundle \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438 \u043f\u0435\u0440\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0439<\/p>\n<p>\u041a\u0430\u043a \u0440\u0435\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 Lazy Loading?<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u00ab\u0440\u0430\u0437\u0431\u0438\u0442\u044c\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u043c\u043e\u0434\u0443\u043b\u0438, \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0445 <strong>\u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437\u0434\u0435\u043b<\/strong><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u00ab\u041f\u0438\u0446\u0446\u0435\u0440\u0438\u044f\u00bb:<\/p>\n<ul>\n<li>\n<p>\u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e <code>\u0413\u043b\u0430\u0432\u043d\u0430\u044f<\/code>, <code>\u041c\u0435\u043d\u044e<\/code>, <code>\u041a\u043e\u043d\u0442\u0430\u043a\u0442\u044b<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u0430 \u0432\u043e\u0442 <strong>\u0430\u0434\u043c\u0438\u043d\u043a\u0443<\/strong> (<code>\/admin<\/code>) \u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430<\/p>\n<\/li>\n<\/ul>\n<h3>\u0411\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/h3>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0440\u043e\u0443\u0442\u0438\u043d\u0433<\/p>\n<pre><code class=\"typescript\">import {Routes} from '@angular\/router'; import {Home} from '.\/components\/home\/home'; import {Menu} from '.\/components\/menu\/menu'; import {Pizza} from '.\/components\/pizza\/pizza'; import {Contacts} from '.\/components\/contacts\/contacts';  export const routes: Routes = [   {path: 'menu', component: Menu},   {path: 'pizza\/:id', component: Pizza},   {path: 'contacts', component: Contacts},   { path: '', redirectTo: 'menu', pathMatch: 'full' } ]; <\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c <strong>\u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0440\u043e\u0443\u0442<\/strong> \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u043a\u0438:<\/p>\n<pre><code class=\"typescript\">export const routes: Routes = [   { path: 'menu', component: Menu },   { path: 'pizza\/:id', component: Pizza },   { path: 'contacts', component: Contacts },   { path: '', redirectTo: 'menu', pathMatch: 'full' },    \/\/ \ud83d\udc47 \u043b\u0435\u043d\u0438\u0432\u044b\u0439 \u0440\u043e\u0443\u0442 \u0441\u043e standalone \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c   {     path: 'admin',     loadComponent: () =&gt;       import('.\/pages\/admin\/admin').then(m =&gt; m.Admin),   }, ];<\/code><\/pre>\n<h3>\u041f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0430\u0434\u043c\u0438\u043d\u043a\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438 \u0443 \u043d\u0435\u0451 \u0435\u0441\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b (<code>\/admin\/orders<\/code>, <code>\/admin\/settings<\/code>), \u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 <code>routes<\/code><\/p>\n<pre><code class=\"typescript\">export const routes: Routes = [   { path: 'menu', component: Menu },   { path: 'pizza\/:id', component: Pizza },   { path: 'contacts', component: Contacts },   { path: '', redirectTo: 'menu', pathMatch: 'full' },    {     path: 'admin',     loadChildren: () =&gt;       import('.\/pages\/admin\/admin.routes').then(m =&gt; m.adminRoutes),   }, ];<\/code><\/pre>\n<p>\u0410 \u0432\u043d\u0443\u0442\u0440\u0438 <code>admin.routes.ts:<\/code><\/p>\n<pre><code class=\"typescript\">import { Routes } from '@angular\/router'; import { AdminDashboard } from '.\/dashboard\/dashboard'; import { AdminOrders } from '.\/orders\/orders';  export const adminRoutes: Routes = [   { path: '', component: AdminDashboard },   { path: 'orders', component: AdminOrders }, ]; <\/code><\/pre>\n<h3>\u041a\u043e\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c loadComponent, \u0430 \u043a\u043e\u0433\u0434\u0430 loadChildren?<\/h3>\n<ul>\n<li>\n<p><code>loadComponent<\/code> \u2014 \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f <strong>\u043e\u0434\u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430<\/strong>, \u0442\u0438\u043f\u0430 <code>\/admin<\/code>.<\/p>\n<\/li>\n<li>\n<p><code>loadChildren<\/code> \u2014 \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f <strong>\u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0430<\/strong>, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <code>\/admin\/orders<\/code>, <code>\/admin\/settings<\/code><\/p>\n<\/li>\n<\/ul>\n<h3>\ud83c\udfaf \u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>\u041c\u044b \u043f\u0440\u043e\u0448\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0443\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u044b (<code>path<\/code>, <code>component<\/code>),<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0443\u0447\u0438\u043b\u0438\u0441\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 (<code>:id<\/code>, <code>queryParams<\/code>),<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043d\u0430 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 (<code>redirectTo<\/code>, <code>pathMatch<\/code>, <code>title<\/code>),<\/p>\n<\/li>\n<li>\n<p>\u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u043b\u0435\u043d\u0438\u0432\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0440\u043e\u0443\u0442\u044b<\/p>\n<\/li>\n<\/ul>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0435\u043d <strong>Angular Router<\/strong> \u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 <\/p>\n<p>\u0425\u043e\u0442\u0438\u0442\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0441\u0430\u0439\u0442-\u0432\u0438\u0437\u0438\u0442\u043a\u0443, \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043c\u0430\u0433\u0430\u0437\u0438\u043d \u0438\u043b\u0438 \u0446\u0435\u043b\u0443\u044e \u0430\u0434\u043c\u0438\u043d\u043a\u0443 \u2014 \u0432\u0441\u0451 \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u0442\u0435\u0445 \u0437\u043d\u0430\u043d\u0438\u044f\u0445, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/938804\/\"> https:\/\/habr.com\/ru\/articles\/938804\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-471293","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=471293"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/471293\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=471293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=471293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=471293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}