{"id":615,"date":"2023-03-07T05:00:00","date_gmt":"2023-03-07T13:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=615"},"modified":"2023-03-04T12:11:43","modified_gmt":"2023-03-04T20:11:43","slug":"standalone-application-and-router-config","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/standalone-application-and-router-config\/","title":{"rendered":"Standalone Application and Router config"},"content":{"rendered":"\n<p>With this daily post, let&#8217;s get back to the new Angular standalone features. So far, we have seen how to create standalone components, add <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/adding-dependencies-to-standalone-components\/\" target=\"_blank\" rel=\"noopener\" title=\"\">dependencies<\/a>, and <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/lazy-loading-standalone-components\/\" target=\"_blank\" rel=\"noopener\" title=\"\">lazy-loading<\/a> of standalone components.<\/p>\n\n\n\n<p>Since the primary goal of standalone components is to have less <code>NgModules<\/code>, what about creating an Angular application with no <code>NgModule<\/code> at all?<\/p>\n\n\n\n<p>Enter the <code><a href=\"https:\/\/angular.io\/api\/platform-browser\/bootstrapApplication\" target=\"_blank\" rel=\"noopener\" title=\"\">bootstrapApplication<\/a><\/code> function (from <code>@angular\/platform-browser<\/code>). All it needs is the root standalone <code>AppComponent<\/code> as a parameter:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-3.png\" alt=\"\" class=\"wp-image-617\" width=\"393\" height=\"311\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-3.png 648w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-3-300x237.png 300w\" sizes=\"auto, (max-width: 393px) 100vw, 393px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>And that&#8217;s it. No <code>AppModule<\/code> needed. Now you&#8217;re probably wondering: How to add some router config?<\/p>\n\n\n\n<p>There&#8217;s a <code><a href=\"https:\/\/angular.io\/api\/router\/provideRouter\" target=\"_blank\" rel=\"noopener\" title=\"\">provideRouter<\/a><\/code> function for that, along with several <a href=\"https:\/\/blog.angulartraining.com\/router-utility-functions-in-angular-14-8d843b50d2e2\" target=\"_blank\" rel=\"noopener\" title=\"\">router utility functions<\/a> to configure preloading, guards, error handling, <a href=\"https:\/\/angular.io\/api\/router#functions\" target=\"_blank\" rel=\"noopener\" title=\"\">and more<\/a>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-4.png\" alt=\"\" class=\"wp-image-618\" width=\"535\" height=\"190\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-4.png 756w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-4-300x106.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-4-750x268.png 750w\" sizes=\"auto, (max-width: 535px) 100vw, 535px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>Last but not least, if you need to use services from a third-party module and don&#8217;t want to import the other features of that module (components\/pipes\/directives), you can also do the following:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-5.png\" alt=\"\" class=\"wp-image-619\" width=\"573\" height=\"201\" srcset=\"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-5.png 804w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-5-300x105.png 300w, https:\/\/www.angulartraining.com\/daily-newsletter\/wp-content\/uploads\/2023\/03\/image-5-768x269.png 768w\" sizes=\"auto, (max-width: 573px) 100vw, 573px\" \/><\/figure>\n<\/div>\n\n\n<p><\/p>\n\n\n\n<p>As you can see, standalone components have paved the way for many new function-based features (instead of classes\/services), and we&#8217;ll see even more of those in the coming posts.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With this daily post, let&#8217;s get back to the new Angular standalone features. So far, we have seen how to create standalone components, add dependencies, and lazy-loading of standalone components. Since the primary goal of standalone components is to have less NgModules, what about creating an Angular application with no NgModule at all? Enter the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,21,25,23],"tags":[],"class_list":["post-615","post","type-post","status-publish","format-standard","hentry","category-angular","category-architecture","category-routing","category-standalone"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=615"}],"version-history":[{"count":2,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/615\/revisions"}],"predecessor-version":[{"id":620,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/615\/revisions\/620"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}