{"id":6199,"date":"2022-05-25T18:59:55","date_gmt":"2022-05-25T16:59:55","guid":{"rendered":"https:\/\/www.angulararchitects.io\/?p=6199"},"modified":"2022-05-25T18:59:55","modified_gmt":"2022-05-25T16:59:55","slug":"routing-and-lazy-loading-with-standalone-components","status":"publish","type":"post","link":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/","title":{"rendered":"Routing and Lazy Loading with Angular&#8217;s Standalone Components"},"content":{"rendered":"<div class=\"wp-post-series-box series-angulars-future-without-ngmodules wp-post-series-box--expandable\">\n\t\t\t<input id=\"collapsible-series-angulars-future-without-ngmodules69f385b35cbc7\" class=\"wp-post-series-box__toggle_checkbox\" type=\"checkbox\">\n\t\n\t<label\n\t\tclass=\"wp-post-series-box__label\"\n\t\t\t\t\tfor=\"collapsible-series-angulars-future-without-ngmodules69f385b35cbc7\"\n\t\t\ttabindex=\"0\"\n\t\t\t\t>\n\t\t<p class=\"wp-post-series-box__name wp-post-series-name\">\n\t\t\tThis is post 4 of 8 in the series <em>&ldquo;Angular&#039;s Future with Standalone Components&rdquo;<\/em>\t\t<\/p>\n\t\t\t<\/label>\n\n\t\t\t<div class=\"wp-post-series-box__posts\">\n\t\t\t<ol>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/angulars-future-without-ngmodules-lightweight-solutions-on-top-of-standalone-components\/\">Angular&#8217;s Future Without NgModules &#8211; Part 1: Lightweight Solutions Using Standalone Components<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/angulars-future-without-ngmodules-part-2-what-does-that-mean-for-our-architecture\/\">Angular&#8217;s Future Without NgModules &#8211; Part 2: What Does That Mean for Our Architecture?<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/4-ways-to-prepare-for-angulars-upcoming-standalone-components\/\">4 Ways to Prepare for Angular&#8217;s Upcoming Standalone Components<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><span class=\"wp-post-series-box__current\">Routing and Lazy Loading with Angular&#8217;s Standalone Components<\/span><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/angular-elements-web-components-with-standalone-components\/\">Angular Elements: Web Components with Standalone Components<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/the-refurbished-httpclient-in-angular-15-standalone-apis-and-functional-interceptors\/\">The Refurbished HttpClient in Angular 15 &#8211; Standalone APIs and Functional Interceptors<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/testing-angular-standalone-components\/\">Testing Angular Standalone Components<\/a><\/li>\n\t\t\t\t\t\t\t\t\t<li><a href=\"https:\/\/www.angulararchitects.io\/en\/blog\/tutorial-automatically-migrating-to-standalone-components-in-3-steps\/\">Automatic Migration to Standalone Components in 3 Steps<\/a><\/li>\n\t\t\t\t\t\t\t<\/ol>\n\t\t<\/div>\n\t<\/div>\n<p><strong>Update on 2022-10-10<\/strong>: Updated for <em>Angular 14.2.0<\/em>.<\/p>\n<p>Since its first days, the Angular Router has always been<br \/>\nquite coupled to NgModules. Hence, one question that comes up when moving to Standalone Components is: How will routing and lazy loading work without NgModules? This article provides answers and also shows, why the router will become more important for Dependency Injection.<\/p>\n<blockquote><p>\nBig thanks to <a href=\"https:\/\/twitter.com\/pkozlowski_os\">Pawel Kozlowski<\/a> from the Angular team for proofreading this article!<\/p>\n<p>The <strong>\ud83d\udcc2 source code<\/strong> for the examples used here can be found in the form of a traditional <a href=\"https:\/\/github.com\/manfredsteyer\/standalone-example-cli\">Angular CLI workspace<\/a> and as an <a href=\"https:\/\/github.com\/manfredsteyer\/standalone-example-nx\">Nx workspace<\/a> that uses libraries as a replacement for NgModules.\n<\/p><\/blockquote>\n<h2>Providing the Routing Configuration<\/h2>\n<p>When bootstrapping a standalone component, we can provide services for the root scope. These are services you used to provide in your <code>AppModule<\/code>. Meanwhile, the Router provides a function <code>provideRouter<\/code> that returns all providers we need to register here:<\/p>\n<pre><code class=\"language-typescript\">\/\/ main.ts\n\nimport { importProvidersFrom } from &#039;@angular\/core&#039;;\nimport { bootstrapApplication } from &#039;@angular\/platform-browser&#039;;\nimport { \n    PreloadAllModules, \n    provideRouter, \n    withDebugTracing, \n    withPreloading, \n    withRouterConfig \n} \nfrom &#039;@angular\/router&#039;;\n\nimport { APP_ROUTES } from &#039;.\/app\/app.routes&#039;;\n[...]\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    importProvidersFrom(HttpClientModule),\n    provideRouter(APP_ROUTES, \n      withPreloading(PreloadAllModules),\n      withDebugTracing(),\n    ),\n\n    [...]\n\n    importProvidersFrom(TicketsModule),\n    provideAnimations(),\n    importProvidersFrom(LayoutModule),\n  ]\n});<\/code><\/pre>\n<p>The function <code>provideRouter<\/code> not only takes the root routes but also the implementation of additional router features. These features are passed with functions having the naming pattern <code>withXYZ<\/code>, e. g. <code>withPreloading<\/code> or <code>withDebugTracing<\/code>. As functions can easily be tree-shaken, this design decisions makes the whole router more tree-shakable. <\/p>\n<blockquote><p>\nWith the discussed functions, the Angular team also introduces a naming pattern, library authors should follow. Hence, when adding a new library, we just need to look out for an <code>provideXYZ<\/code> and for some optional <code>withXYZ<\/code> functions.\n<\/p><\/blockquote>\n<p>As currently not every library comes with a <code>provideXYZ<\/code> function yet, Angular comes with the bridging function <code>importProvidersFrom<\/code>. It allows to get hold of all the providers defined in existing <code>NgModules<\/code> and hence is the key for using them with Standalone Components. <\/p>\n<p>I'm quite sure, the usage of <code>importProvidersFrom<\/code> will peak off over time, as more and more libraries will provide functions for directly configuring their providers. For instance, NGRX recently introduced a <code>provideStore<\/code> and a <code>provideEffects<\/code> function.<\/p>\n<h2>Using Router Directives<\/h2>\n<p>After setting up the routes, we also need to define a placeholder where the Router displays the activated component and links for switching between them. To get the directives needed for this, you might directly import the RouterModule into your Standalone Component. However, a better alternative is to just import the directives you need:<\/p>\n<pre><code class=\"language-typescript\">@Component({\n  standalone: true,\n  selector: &#039;app-root&#039;,\n  imports: [\n    \/\/ Just import the RouterModule:\n    \/\/ RouterModule,\n\n    \/\/ Better: Just import what you need:\n    RouterOutlet,\n    RouterLinkWithHref,\n\n    NavbarComponent,\n    SidebarComponent,\n  ],\n  templateUrl: &#039;.\/app.component.html&#039;,\n  styleUrls: [&#039;.\/app.component.css&#039;]\n})\nexport class AppComponent {\n    [...]\n}<\/code><\/pre>\n<p>Just importing the actually needed directives is possible, because the router exposed them as Standalone Directives. Please note that <code>RouterLinkWithHref<\/code> is needed if you use <code>routerLink<\/code> with an <code>a<\/code>-tag; in all other cases you should import <code>RouterLink<\/code> instead. While this might sound confusing, this is nothing we need to worry about in the mid-term when IDEs start providing auto-imports for Standalone Components.<\/p>\n<h2>Lazy Loading with Standalone Components<\/h2>\n<p>In the past, a lazy route pointed to an <code>NgModule<\/code> with child routes. As there are no <code>NgModules<\/code> anymore, <code>loadChildren<\/code> can now directly point to a lazy routing configuration:<\/p>\n<pre><code class=\"language-typescript\">\/\/ app.routes.ts\n\nimport { Routes } from &#039;@angular\/router&#039;;\nimport { HomeComponent } from &#039;.\/home\/home.component&#039;;\n\nexport const APP_ROUTES: Routes = [\n    {\n        path: &#039;&#039;,\n        pathMatch: &#039;full&#039;,\n        redirectTo: &#039;home&#039;\n    },\n    {\n        path: &#039;home&#039;,\n        component: HomeComponent\n    },\n\n    \/\/ Option 1: Lazy Loading another Routing Config\n    {\n        path: &#039;flight-booking&#039;,\n        loadChildren: () =&gt;\n            import(&#039;.\/booking\/flight-booking.routes&#039;)\n                .then(m =&gt; m.FLIGHT_BOOKING_ROUTES)\n    },\n\n    \/\/ Option 2: Directly Lazy Loading a Standalone Component\n    {\n        path: &#039;next-flight&#039;,\n        loadComponent: () =&gt; \n            import(&#039;.\/next-flight\/next-flight.component&#039;)\n                .then(m =&gt; m.NextFlightComponent)\n    },\n    [...]\n];<\/code><\/pre>\n<p>This removes the indirection via an <code>NgModule<\/code> and makes our code more explicit. As an alternative, a lazy route can also directly point to a Standalone Component. For this, the above shown <code>loadComponent<\/code> property is used.<\/p>\n<p>I expect that most teams will favor the first option, because normally, an application needs to lazy loading several routes that go together.<\/p>\n<h2>Environment Injectors: Services for Specific Routes<\/h2>\n<p>With <code>NgModule<\/code>s, each lazy module introduced a new injector and hence a new injection scope. This scope was used for providing services only needed by the respective lazy chunk. <\/p>\n<p>To cover such use cases, the Router now allows for introducing providers for each route. These services can be used by the route in question and their child routes:<\/p>\n<pre><code class=\"language-typescript\">\/\/ booking\/flight-booking.routes.ts\n\nexport const FLIGHT_BOOKING_ROUTES: Routes = [{\n    path: &#039;&#039;,\n    component: FlightBookingComponent,\n    providers: [\n        provideBookingDomain(config)\n    ],\n    children: [\n        {\n            path: &#039;&#039;,\n            pathMatch: &#039;full&#039;,\n            redirectTo: &#039;flight-search&#039;\n        },\n        {\n            path: &#039;flight-search&#039;,\n            component: FlightSearchComponent\n        },\n        {\n            path: &#039;passenger-search&#039;,\n            component: PassengerSearchComponent\n        },\n        {\n            path: &#039;flight-edit\/:id&#039;,\n            component: FlightEditComponent\n        }\n    ]\n}];<\/code><\/pre>\n<p>As shown here, we can provide services for several routes by grouping them as child routes. In these cases, a component-less parent route with an empty path (<code>path: &#039;&#039;<\/code>) is used. This pattern is already used for years to assign Guards to a group of routes.<\/p>\n<p>Technically, using adding a <code>providers<\/code> array to a router configuration introduces a new injector at the level of the route. Such an injector is called Environment Injector and replaces the concept of the former (Ng)Module Injectors. The root injector and the platform injector are further Environment Injectors.<\/p>\n<p>Interestingly, this also decouples lazy loading from introducing further injection scopes. Previously, each <strong>lazy<\/strong> <code>NgModule<\/code> introduced a new injection scope, while <strong>non-lazy<\/strong> <code>NgModule<\/code>s never did. Now, lazy loading itself doesn't influence the scopes. Instead, now, you define new scopes by adding a <code>providers<\/code> array to your routes, <strong>regardless<\/strong> if the route is lazy or not. <\/p>\n<p>The Angular team recommends to use this providers array with caution and to <strong>favor<\/strong> <code>providedIn: &#039;root&#039;<\/code> instead. As already mentioned in a previous article of this series, also <code>providedIn: &#039;root&#039;<\/code> allows for lazy loading. If you just use a services provided with <code>providedIn: &#039;root&#039;<\/code> in lazy parts of your application, they will only be loaded together with them.<\/p>\n<p>However, there is one situation where <code>providedIn: &#039;root&#039;<\/code> does not work and hence the providers array shown is needed, namely if you need to pass a configuration to a library. I've already indicated this in the above example by passing a config object to my custom <code>provideBookingDomain<\/code>. The next section provides a more elaborated example for this using NGRX.<\/p>\n<h2>Setting up NGRX and Feature Slices<\/h2>\n<p>To illustrate how to use libraries adopted for Standalone Components with lazy loading, let's see how to setup NGRX. Let's start with providing the needed global services:<\/p>\n<pre><code class=\"language-typescript\">import { bootstrapApplication } from &#039;@angular\/platform-browser&#039;;\n\nimport { provideStore } from &#039;@ngrx\/store&#039;;\nimport { provideEffects } from &#039;@ngrx\/effects&#039;;\nimport { provideStoreDevtools } from &#039;@ngrx\/store-devtools&#039;;\n\nimport { reducer } from &#039;.\/app\/+state&#039;;\n\n[...]\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    importProvidersFrom(HttpClientModule),\n    provideRouter(APP_ROUTES, \n      withPreloading(PreloadAllModules),\n      withDebugTracing(),\n    ),\n\n    \/\/ Setup NGRX:\n    provideStore(reducer),\n    provideEffects([]),\n    provideStoreDevtools(),\n\n    importProvidersFrom(TicketsModule),\n    provideAnimations(),\n    importProvidersFrom(LayoutModule),\n  ]\n});<\/code><\/pre>\n<p>For this, we go with the functions <code>provideStore<\/code>, <code>provideEffects<\/code>, and <code>provideStoreDevtools<\/code> NGRX comes with since version <code>14.3<\/code>.<\/p>\n<p>To allow lazy parts of the application to have their own feature slices, we call <code>provideState<\/code> and <code>provideEffects<\/code> in the respective routing configuration:<\/p>\n<pre><code class=\"language-typescript\">import { provideEffects } from &quot;@ngrx\/effects&quot;;\nimport { provideState } from &quot;@ngrx\/store&quot;;\n\nexport const FLIGHT_BOOKING_ROUTES: Routes = [{\n    path: &#039;&#039;,\n    component: FlightBookingComponent,\n    providers: [\n        provideState(bookingFeature),\n        provideEffects([BookingEffects])\n    ],\n    children: [\n        {\n            path: &#039;flight-search&#039;,\n            component: FlightSearchComponent\n        },\n        {\n            path: &#039;passenger-search&#039;,\n            component: PassengerSearchComponent\n        },\n        {\n            path: &#039;flight-edit\/:id&#039;,\n            component: FlightEditComponent\n        }\n    ]\n}];<\/code><\/pre>\n<p>While <code>provideStore<\/code> sets up the store at root level, <code>provideState<\/code> sets up additional feature slices. For this, you can provide a feature or just a branch name with a reducer. Interestingly, the function <code>provideEffects<\/code> is used at the root level but also at the level of lazy parts. Hence, it provides the initial effects but also effects needed for a given feature slice.<\/p>\n<h2>Setting up Your Environment: ENVIRONMENT_INITIALIZER<\/h2>\n<p>Some libraries used the constructor of lazy <code>NgModule<\/code> for their initialization. To further support this approach without <code>NgModule<\/code>s, there is now the concept of an <code>ENVIRONMENT_INITIALIZER<\/code>:<\/p>\n<pre><code class=\"language-typescript\">export const FLIGHT_BOOKING_ROUTES: Routes = [{\n    path: &#039;&#039;,\n    component: FlightBookingComponent,\n    providers: [\n        importProvidersFrom(StoreModule.forFeature(bookingFeature)),\n        importProvidersFrom(EffectsModule.forFeature([BookingEffects])),\n        {\n            provide: ENVIRONMENT_INITIALIZER,\n            multi: true,\n            useValue: () =&gt; inject(InitService).init()\n        }\n    ],\n    children: [\n        [...]\n    ]\n}<\/code><\/pre>\n<p>Basically, the <code>ENVIRONMENT_INITIALIZER<\/code> provides a function executed when the Environment Injector is initialized. The flag <code>multi: true<\/code> already indicates that you can have several such initializers per scope.<\/p>\n<h2>What's next? More on Architecture!<\/h2>\n<p>So far, we've seen how to decompose a huge client into several libraries with Standalone Components. However, when dealing with enterprise-scale frontends, several additional questions come in mind:<\/p>\n<ul>\n<li>According to which criteria can we subdivide a huge application into sub-domains?<\/li>\n<li>How can we make sure, the solution is maintainable for years or even decades?<\/li>\n<li>Which options from Micro Frontends are provided by Module Federation?<\/li>\n<\/ul>\n<p>Our free eBook (about 120 pages) covers all these questions and more:<\/p>\n<p><a href=\"https:\/\/www.angulararchitects.io\/book\"><img decoding=\"async\" src=\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/12\/cover-5th-small.png\" alt=\"free ebook\"><\/a><\/p>\n<p>Feel free to <a href=\"https:\/\/www.angulararchitects.io\/en\/book\">download it here<\/a> now!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For lazy loading, we can directly point to further routing configurations but also to Standalone Components.<\/p>\n","protected":false},"author":9,"featured_media":6195,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[18],"tags":[],"class_list":["post-6199","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","post_series-angulars-future-without-ngmodules"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Routing and Lazy Loading with Angular&#039;s Standalone Components - ANGULARarchitects<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Routing and Lazy Loading with Angular&#039;s Standalone Components - ANGULARarchitects\" \/>\n<meta property=\"og:description\" content=\"For lazy loading, we can directly point to further routing configurations but also to Standalone Components.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\" \/>\n<meta property=\"og:site_name\" content=\"ANGULARarchitects\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-25T16:59:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/sujet.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"524\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Manfred Steyer, GDE\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/sujet.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@daniel\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Manfred Steyer, GDE\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\"},\"author\":{\"name\":\"Manfred Steyer, GDE\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#\/schema\/person\/15628efa7af4475ffaaeeb26c5112951\"},\"headline\":\"Routing and Lazy Loading with Angular&#8217;s Standalone Components\",\"datePublished\":\"2022-05-25T16:59:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\"},\"wordCount\":1102,\"publisher\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\",\"url\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\",\"name\":\"Routing and Lazy Loading with Angular's Standalone Components - ANGULARarchitects\",\"isPartOf\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg\",\"datePublished\":\"2022-05-25T16:59:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage\",\"url\":\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg\",\"contentUrl\":\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg\",\"width\":1000,\"height\":318},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.angulararchitects.io\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Routing and Lazy Loading with Angular&#8217;s Standalone Components\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#website\",\"url\":\"https:\/\/www.angulararchitects.io\/en\/\",\"name\":\"ANGULARarchitects\",\"description\":\"AngularArchitects.io\",\"publisher\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.angulararchitects.io\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#organization\",\"name\":\"ANGULARarchitects\",\"alternateName\":\"SOFTWAREarchitects\",\"url\":\"https:\/\/www.angulararchitects.io\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2023\/07\/AA-Logo-RGB-horizontal-inside-knowledge-black.svg\",\"contentUrl\":\"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2023\/07\/AA-Logo-RGB-horizontal-inside-knowledge-black.svg\",\"width\":644,\"height\":216,\"caption\":\"ANGULARarchitects\"},\"image\":{\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/github.com\/angular-architects\",\"https:\/\/www.linkedin.com\/company\/angular-architects\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#\/schema\/person\/15628efa7af4475ffaaeeb26c5112951\",\"name\":\"Manfred Steyer, GDE\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.angulararchitects.io\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a0b59539674d8b71ea1c1f4764b11244b5f499203f1d11b40f37d8f3f90be033?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a0b59539674d8b71ea1c1f4764b11244b5f499203f1d11b40f37d8f3f90be033?s=96&d=mm&r=g\",\"caption\":\"Manfred Steyer, GDE\"},\"sameAs\":[\"https:\/\/x.com\/daniel\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Routing and Lazy Loading with Angular's Standalone Components - ANGULARarchitects","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/","og_locale":"en_US","og_type":"article","og_title":"Routing and Lazy Loading with Angular's Standalone Components - ANGULARarchitects","og_description":"For lazy loading, we can directly point to further routing configurations but also to Standalone Components.","og_url":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/","og_site_name":"ANGULARarchitects","article_published_time":"2022-05-25T16:59:55+00:00","og_image":[{"width":1000,"height":524,"url":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/sujet.jpg","type":"image\/jpeg"}],"author":"Manfred Steyer, GDE","twitter_card":"summary_large_image","twitter_image":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/sujet.jpg","twitter_creator":"@daniel","twitter_misc":{"Written by":"Manfred Steyer, GDE","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#article","isPartOf":{"@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/"},"author":{"name":"Manfred Steyer, GDE","@id":"https:\/\/www.angulararchitects.io\/en\/#\/schema\/person\/15628efa7af4475ffaaeeb26c5112951"},"headline":"Routing and Lazy Loading with Angular&#8217;s Standalone Components","datePublished":"2022-05-25T16:59:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/"},"wordCount":1102,"publisher":{"@id":"https:\/\/www.angulararchitects.io\/en\/#organization"},"image":{"@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage"},"thumbnailUrl":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/","url":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/","name":"Routing and Lazy Loading with Angular's Standalone Components - ANGULARarchitects","isPartOf":{"@id":"https:\/\/www.angulararchitects.io\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage"},"image":{"@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage"},"thumbnailUrl":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg","datePublished":"2022-05-25T16:59:55+00:00","breadcrumb":{"@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#primaryimage","url":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg","contentUrl":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2022\/05\/bg.jpg","width":1000,"height":318},{"@type":"BreadcrumbList","@id":"https:\/\/www.angulararchitects.io\/en\/blog\/routing-and-lazy-loading-with-standalone-components\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.angulararchitects.io\/en\/"},{"@type":"ListItem","position":2,"name":"Routing and Lazy Loading with Angular&#8217;s Standalone Components"}]},{"@type":"WebSite","@id":"https:\/\/www.angulararchitects.io\/en\/#website","url":"https:\/\/www.angulararchitects.io\/en\/","name":"ANGULARarchitects","description":"AngularArchitects.io","publisher":{"@id":"https:\/\/www.angulararchitects.io\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.angulararchitects.io\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.angulararchitects.io\/en\/#organization","name":"ANGULARarchitects","alternateName":"SOFTWAREarchitects","url":"https:\/\/www.angulararchitects.io\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.angulararchitects.io\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2023\/07\/AA-Logo-RGB-horizontal-inside-knowledge-black.svg","contentUrl":"https:\/\/www.angulararchitects.io\/wp-content\/uploads\/2023\/07\/AA-Logo-RGB-horizontal-inside-knowledge-black.svg","width":644,"height":216,"caption":"ANGULARarchitects"},"image":{"@id":"https:\/\/www.angulararchitects.io\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/github.com\/angular-architects","https:\/\/www.linkedin.com\/company\/angular-architects\/"]},{"@type":"Person","@id":"https:\/\/www.angulararchitects.io\/en\/#\/schema\/person\/15628efa7af4475ffaaeeb26c5112951","name":"Manfred Steyer, GDE","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.angulararchitects.io\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a0b59539674d8b71ea1c1f4764b11244b5f499203f1d11b40f37d8f3f90be033?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a0b59539674d8b71ea1c1f4764b11244b5f499203f1d11b40f37d8f3f90be033?s=96&d=mm&r=g","caption":"Manfred Steyer, GDE"},"sameAs":["https:\/\/x.com\/daniel"]}]}},"_links":{"self":[{"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/posts\/6199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/comments?post=6199"}],"version-history":[{"count":0,"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/posts\/6199\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/media\/6195"}],"wp:attachment":[{"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/media?parent=6199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/categories?post=6199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulararchitects.io\/en\/wp-json\/wp\/v2\/tags?post=6199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}