{"id":25192,"date":"2021-02-22T11:17:00","date_gmt":"2021-02-22T05:47:00","guid":{"rendered":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/"},"modified":"2024-09-03T11:24:34","modified_gmt":"2024-09-03T05:54:34","slug":"angular-routing-tutorial","status":"publish","type":"post","link":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/","title":{"rendered":"Angular Tutorial for Beginners - Everything you need to know"},"content":{"rendered":"\n<p>Let\u2019s kickstart our Angular Routing tutorial with its introduction. You can also take up a free<a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/angular7-for-beginners\" target=\"_blank\" rel=\"noreferrer noopener\"> Angular course <\/a>that will help you learn more about the concept. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"introduction-to-angular-routing\"><strong>Introduction to Angular Routing<\/strong><\/h2>\n\n\n\n<p>Navigating from one page to another page in a web application is known as Routing. Routing in Angular is called Angular Routing. Below is a familiar model of application navigation which a web browser follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The web browser navigates to a corresponding page when you enter a URL in the address bar<\/li>\n\n\n\n<li>The browser navigates to a new page when you click a link on the page<\/li>\n\n\n\n<li>When you click the browser\u2019s forward and backward buttons, it navigates to the corresponding pages through the history of pages you have visited<\/li>\n<\/ul>\n\n\n\n<p>The Angular Router adopts from this model for navigation. Angular is a Single Page Application (SPA) that uses multiple Angular routes. In SPA, all the functionalities of your application exist in a single HTML page. The browser renders only the parts that are required for the user rather than loading a new page.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe title=\"Introduction to AngularJS | AngularJS for Beginners | Learn AngularJS | Great Learning\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/D5N2skVmM_M?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites-for-angular-routing\"><strong>Prerequisites for Angular Routing<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-html\"><strong>1. HTML<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stands for Hypertext Markup Language<\/li>\n\n\n\n<li>It is a markup language for creating web pages\/documents<\/li>\n<\/ul>\n\n\n\n<p>General Syntax:&nbsp;<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n&lt;title&gt;Title of the Page&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;h1&gt;Welcome to Great Learning!&lt;\/h1&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"2-css\"><strong>2. CSS<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Stands for Cascading Style Sheets<\/li>\n\n\n\n<li>It is more responsible for the look and feel of the webpage<\/li>\n\n\n\n<li>You can select elements from HTML and apply styling to it<\/li>\n<\/ul>\n\n\n\n<p>General Syntax:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: css; title: ; notranslate\" title=\"\">\nselector {\nproperty1 : value1; \nproperty2 : value2; \nproperty3 : value3;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"3-javascript\"><strong>3. JavaScript<\/strong><\/h3>\n\n\n\n<p>It is scripting or programming language, which allows you to implement complex features on web applications.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Arrays<\/li>\n\n\n\n<li>Objects<\/li>\n\n\n\n<li>Functions<\/li>\n\n\n\n<li>Control Flow Statements<\/li>\n\n\n\n<li>DOM Manipulation<\/li>\n\n\n\n<li>DOM Events<\/li>\n\n\n\n<li>Closure<\/li>\n\n\n\n<li>Prototype<\/li>\n\n\n\n<li>OOPs<\/li>\n<\/ul>\n\n\n\n<p>General Syntax:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n&lt;script&gt;\n\/\/JavaScript Code\n&lt;\/script&gt;\n<\/pre><\/div>\n\n\n    <div class=\"courses-cta-container\">\n        <div class=\"courses-cta-card\">\n            <div class=\"courses-cta-header\">\n                <div class=\"courses-learn-icon\"><\/div>\n                <span class=\"courses-learn-text\">Academy PRO +<\/span>\n            <\/div>\n            <p class=\"courses-cta-title\">\n                <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/advanced-javascript-development\" class=\"courses-cta-title-link\">Advanced JavaScript Course<\/a>\n            <\/p>\n            <p class=\"courses-cta-description\">Learn advanced JavaScript concepts, including ES6+, async programming, and modern frameworks. Strengthen your skills and build dynamic applications to become a proficient JavaScript developer.<\/p>\n            <div class=\"courses-cta-stats\">\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-user-icon\"><\/div>\n                    <span>4.5 learning Hrs<\/span>\n                <\/div>\n                <div class=\"courses-stat-item\">\n                    <div class=\"courses-stat-icon courses-star-icon\"><\/div>\n                    <span>2 Projects<\/span>\n                <\/div>\n            <\/div>\n            <a href=\"https:\/\/www.mygreatlearning.com\/academy\/premium\/advanced-javascript-development\" class=\"courses-cta-button\">\n                Enroll in Advanced JS Course\n                <div class=\"courses-arrow-icon\"><\/div>\n            <\/a>\n        <\/div>\n    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-angular-cli\"><strong>4. Angular CLI<\/strong><\/h3>\n\n\n\n<p>Angular CLI is a command-line interface tool that helps generate, develop, and maintain <a href=\"https:\/\/www.mygreatlearning.com\/blog\/top-angular-projects\/\">Angular projects<\/a> directly from a command shell.<\/p>\n\n\n\n<p>With the knowledge of these prerequisites, you can ensure that you can clearly understand the tutorial of Angular Routing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-of-angular-routing\"><strong>Installation of Angular Routing<\/strong><\/h2>\n\n\n\n<p>Now that you have a basic understanding of Angular Routing, let\u2019s begin with the tutorial on the installation of Angular Routing to your application.<\/p>\n\n\n\n<p>Firstly, you must install the Node Package Manager, i.e. <a href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>npm<\/em><\/a><em> <\/em>and <a href=\"https:\/\/angular.io\/cli\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Angular CLI<\/em><\/a> on your system.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"installation-of-node-js\"><strong>Installation of Node.js<\/strong><\/h3>\n\n\n\n<p><strong>Step-1:<\/strong> You need to download the Node Package Manager from its official website:<br><a rel=\"noreferrer noopener\" href=\"https:\/\/nodejs.org\/en\/download\/\" target=\"_blank\">https:\/\/nodejs.org\/en\/download\/<\/a><\/p>\n\n\n\n<p><strong>Step-2:<\/strong> You will see different kinds to install Node.js. I will choose Windows as it suits my system configurations. You can select any configuration that is suitable for your system.<\/p>\n\n\n\n<p><strong>Step-3:<\/strong> Once the software is downloaded, open the file to run the setup. An installation wizard window will appear. Choose \u2018Next\u2019 to move further into the installation process.<\/p>\n\n\n\n<p><strong>Step-4:<\/strong> Next, tick the \u2018I Agree with the terms and conditions\u2019 checkbox that pops up. Later, choose the location where you want to install Node.js on your system and click the \u2018Next\u2019 button.<\/p>\n\n\n\n<p><strong>Step-5:<\/strong> The custom setup appears. You don\u2019t need to change anything. Just click \u2018Next\u2019 to the move to the next step.<\/p>\n\n\n\n<p><strong>Step-6:<\/strong> Now, it will ask whether you want to install \u2018Chocolatey\u2019 or not. Chocolatey is an NPM for Windows, which illustrates proper package management concepts, allowing you to version things, manage dependencies and the order of installation, adequate inventory management, and other numerous features. So, I recommend you to install it as it is a convenient tool.<\/p>\n\n\n\n<p>Click on the checkbox and choose the \u2018Next\u2019 button.<\/p>\n\n\n\n<p><strong>Step-7:<\/strong> Next, click the \u2018Install\u2019 button for the installation. After the installation, the final window pops up saying \u2018Completed the Node.js Setup Wizard\u2019. Click \u2018Finish\u2019, and Node.js is good to go.<\/p>\n\n\n\n<p><strong>Step-8:<\/strong> To verify whether the installation is successful, type the command \u2018node -v\u2019 to check for the version.<\/p>\n\n\n\n<p>As displayed in the above image, you can ensure that the installation of Node.js is successful.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-of-angular-cli\"><strong>Installation of Angular CLI<\/strong><\/h2>\n\n\n\n<p><strong>Step-1: <\/strong>To install Angular CLI, type the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnpm install -g @angular\/cli\n<\/pre><\/div>\n\n\n<p>The command will download and install the latest Angular CLI version globally (the <em>-g <\/em>extension) on your device.&nbsp;<\/p>\n\n\n\n<p><strong>Step-2: <\/strong>Google will ask you the following question:<\/p>\n\n\n\n<p>\u201cWould you like to share anonymous usage data with the Angular Team at Google under Google\u2019s Privacy Policy at <a href=\"https:\/\/policies.google.com\/privacy\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/policies.google.com\/privacy<\/a>?\u201d<\/p>\n\n\n\n<p>You can either type \u2018yes\u2019 or \u2018no\u2019 that depends on yourself.<\/p>\n\n\n\n<p><strong>Step-3:<\/strong> Angular CLI will be installed, and to verify it, type the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng --version\n<\/pre><\/div>\n\n\n<p>As displayed in the above image, you can ensure that the installation of Angular CLI is successful.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installation-of-angular-material\"><strong>Installation of Angular Material<\/strong><\/h2>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/material.angular.io\/\" target=\"_blank\">Angular Material<\/a> is a UI (User Interface) component library for Angular. You can design your application in an organised manner and attract users with unique designs like styles and shapes. Angular Material drives your application to become more consistent, fast, versatile, and design responsive websites.<\/p>\n\n\n\n<p><strong>Step-1:<\/strong> Moving ahead, change the path directory to your Angular project and type the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng add @angular\/material\n\n<\/pre><\/div>\n\n\n<p>It will ask you to select a prebuilt or a custom theme, as shown below:<\/p>\n\n\n\n<p><strong>Step-2:<\/strong> Choose the \u201cIndigo\/Pink\u201d prebuilt theme. It is the default theme to style your application. If you select the \u201cCustom\u201d theme, you can customise your theme files that include all common styles.<strong>Step-3: <\/strong>Next, type \u2018y\u2019 to set up global Angular Material typography styles.<\/p>\n\n\n\n<p><strong>Step-4:<\/strong> Type \u2018Y\u2019, i.e., \u2018Yes\u2019 to set up browser animations for Angular Material.&nbsp;<\/p>\n\n\n\n<p>Browser animations help in making your application more fun and easier to use. They help in improving your app and user experience that attracts the attention of users.<\/p>\n\n\n\n<p>Eventually, Angular Materials will be installed on your project.<\/p>\n\n\n\n<p><strong>Creating Your Angular Routing Project<\/strong>: Now, create a directory or folder called \u2018Angular Routing\u2019 and change the path to this directory using the <em>cd <\/em>command on your Windows Command Prompt or any other CLI which you are using. You need to type the following command to change the path and navigate into the directory:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd C:\/Users\/Your_System_Name\/Desktop\/Angular Routing\n\n<\/pre><\/div>\n\n\n<p>The path mentioned above is where I will create a new Angular project on my system to teach you about Angular Routing.<\/p>\n\n\n\n<p>To create a new Angular project, type the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng new angular-routing-tutorial\n<\/pre><\/div>\n\n\n<p>First, it will ask you to enforce stricter type checking and stricter bundle budgets in the workspace, as shown below:<\/p>\n\n\n\n<p>Choose \u2018y\u2019, i.e., \u2018yes\u2019 so that this setting helps you improve maintainability and catch bugs ahead of time. Next, it will ask you to add Angular Routing to your project.<\/p>\n\n\n\n<p>Type \u2018y\u2019 to add Angular Routing to your project. Moving further, it will ask you to choose a styling format.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Choose \u2018CSS\u2019 for installing the default CSS stylesheet on your web application. The stylesheet will comprise all the other stylesheets.&nbsp;<\/p>\n\n\n\n<p>Now, click the \u2018Enter\u2019 button and eventually, your new <em>angular-routing-tutorial<\/em> project will be created in your directory. Navigate to your project by typing the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd angular-routing-tutorial\n<\/pre><\/div>\n\n\n<p>Suppose, you have already created an Angular project and would like to add Angular Routing to the existing project, you can effortlessly type the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng generate module app-routing --module app --flat\n<\/pre><\/div>\n\n\n<p>The command will add routing to your existing project generating the <em>app-routing.module.ts <\/em>file into your <em>angular-routing-tutorial\/src\/app <\/em>directory. The generated file will have the following code:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport { NgModule } from &#039;@angular\/core&#039;;\nimport { RouterModule, Routes } from &#039;@angular\/router&#039;;\nconst routes: Routes = &#x5B;];\n@NgModule({\n  imports: &#x5B;RouterModule.forRoot(routes)],\n  exports: &#x5B;RouterModule]\n})\nexport class AppRoutingModule { }\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"routing-between-app-and-first-components\"><strong>Routing between App and First Components<\/strong><\/h2>\n\n\n\n<p>First, I will begin with how to navigate from the App component to the First component. Moving ahead, generate a component named <em>first<\/em> using any of the following commands:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng generate component first\n<\/pre><\/div>\n\n\n<p>OR<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng g c first\n<\/pre><\/div>\n\n\n<p>The command will create the <em>first<\/em> component in the <em>src\/app <\/em>directory. The file comprises the following sub-components:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>first.component.css<\/li>\n\n\n\n<li>first.component.html<\/li>\n\n\n\n<li>first.component.spec.ts<\/li>\n\n\n\n<li>first.component.ts<\/li>\n<\/ol>\n\n\n\n<p>To navigate between the App and First components, open the <em>app.component.html<\/em> file on your project and erase all the existing code. Next, write the new code as follows:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;mat-toolbar color=&quot;primary&quot;&gt;\n  &amp;lt;span&gt;Angular Routing Tutorial: Great Learning&amp;lt;\/span&gt;\n&amp;lt;\/mat-toolbar&gt;\n&amp;lt;router-outlet&gt;&amp;lt;\/router-outlet&gt;\n\n<\/pre><\/div>\n\n\n<p><em>&lt;router-outlet&gt;<\/em> is a router directive from the router library. It guides the router where to display the routed views.<\/p>\n\n\n\n<p><em>&lt;mat-toolbar&gt;<\/em> is a component from Angular Material, used for headers and titles. You can change the color of the Toolbar using the <em>color<\/em> property. By default, a neutral background colour is used by toolbars, which is based on the current theme, i.e. either light or dark. You can opt for three default themes: <em>\u2018primary\u2019<\/em>, <em>\u2018accent\u2019<\/em>, or <em>\u2018warn\u2019<\/em>.To use this toolbar, import it in the <em>app.module.ts<\/em> file from <em>angular\/material<\/em> using the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport { MatToolbarModule } from &#039;@angular\/material\/toolbar&#039;;\n<\/pre><\/div>\n\n\n<p>Now, add the <em>MatToolbarModule<\/em> module in the <em>imports: [ ]<\/em> section located in the <em>app.module.ts<\/em> file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimports: &#x5B;\n    BrowserModule,\n    AppRoutingModule,\n    BrowserAnimationsModule,\n    MatToolbarModule\n],\n<\/pre><\/div>\n\n\n<p>Now, execute your project by running the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng serve -o\n\n<\/pre><\/div>\n\n\n<p>The command opens your project on the default browser of your system, which is as follows:<\/p>\n\n\n\n<p>Now, I will create a route for your <em>first <\/em>component. Open the <em>first.component.html<\/em> file to write the code for displaying the contents of the page.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;h2&gt;The First component welcomes you!&amp;lt;\/h2&gt;\n<\/pre><\/div>\n\n\n<p>Now, import \u2018FirstComponent\u2019 in the <em>app-routing.module.ts<\/em> file, as shown below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport { FirstComponent } from &#039;.\/first\/first.component&#039;;\n<\/pre><\/div>\n\n\n<p>Moving ahead, open the <em>app-routing.module.ts<\/em> file to create a path for the <em>first <\/em>component in the <em>Routes=[ ]<\/em> section.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst routes: Routes = &#x5B;\n  { path: &#039;first&#039;, component: FirstComponent }\n];\n<\/pre><\/div>\n\n\n<p>The code will create a route for the <em>first<\/em> component<em>.<\/em> You can view the component using the following URL on your browser:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhttp:\/\/localhost:4200\/first\n<\/pre><\/div>\n\n\n<p>The URL will display the contents of the <em>first <\/em>component file, as follows:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"routing-between-other-components\"><strong>Routing between Other Components<\/strong><\/h2>\n\n\n\n<p>Here, you will learn how to navigate from one component to another. Like the first component, you need to first generate another component, let\u2019s say \u2018<em>second<\/em>\u2019. Type the following command to generate it:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng g c second\n<\/pre><\/div>\n\n\n<p>Moving forward, we will add a route in the <em>first.component.html<\/em> file to link with the <em>second.component.html<\/em> file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;h2&gt;The First component welcomes you!&amp;lt;\/h2&gt;\n&amp;lt;nav&gt;\n    &amp;lt;a routerLink = &quot;\/second&quot;&gt;Click here to navigate to the Second component&amp;lt;\/a&gt;\n&amp;lt;\/nav&gt;\n\n<\/pre><\/div>\n\n\n<p>Next, we will create a route for the <em>second <\/em>component, similar to the <em>first<\/em> component. Open the <em>second.component.html<\/em> file to write the code for displaying the contents of the page.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;h2&gt;The Second component welcomes you!&amp;lt;\/h2&gt;\n\n<\/pre><\/div>\n\n\n<p>Now, import \u2018SecondComponent\u2019 in the <em>app-routing.module.ts<\/em> file, as shown below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport { SecondComponent } from &#039;.\/second\/second.component&#039;;\n<\/pre><\/div>\n\n\n<p>Moving further, open the <em>app-routing.module.ts<\/em> file to create a path for the <em>second <\/em>component in the <em>Routes=[ ]<\/em> section.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst routes: Routes = &#x5B;\n  { path: &#039;first&#039;, component: FirstComponent },\n  { path: &#039;second&#039;, component: SecondComponent }\n];\n<\/pre><\/div>\n\n\n<p>The code will create a route for the <em>second<\/em> component<em>.<\/em>&nbsp;<\/p>\n\n\n\n<p>First, execute your project by running the following command on your console:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng serve -o\n<\/pre><\/div>\n\n\n<p>Next, open the <em>first<\/em> component using the following URL on your browser:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nhttp:\/\/localhost:4200\/first\n<\/pre><\/div>\n\n\n<p>The URL will display the contents of the <em>first <\/em>component file, as follows:<\/p>\n\n\n\n<p>Click on the \u201cClick here to navigate to the Second component\u201d link to open the <em>second <\/em>component page and display its contents.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"routing-through-buttons\"><strong>Routing through Buttons<\/strong><\/h2>\n\n\n\n<p>Let\u2019s start with navigating through buttons. Firstly, generate two components, namely, \u2018<em>data-science-course<\/em>\u2019 and \u2018<em>devops-course<\/em>\u2019 in your project.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.mygreatlearning.com\/data-science\/courses\">Data Science Course<\/a>: ng g c data-science-course<\/p>\n\n\n\n<p>DevOps Course: ng g c devops-courseLater, I will add a \u201cHomepage\u201d icon and \u201cCourses\u201d menu option to your project. Open the <em>app.component.html<\/em> file and redraft your code as follows:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;mat-toolbar color=&quot;primary&quot;&gt;\n  &amp;lt;span&gt;Angular Routing Tutorial: Great Learning&amp;lt;\/span&gt;\n  &amp;lt;span class=&quot;home-space&quot;&gt;&amp;lt;\/span&gt;\n  &amp;lt;button class=&quot;example-container&quot; mat-icon-button routerLink=&quot;\/&quot;&gt;\n     &amp;lt;mat-icon inline=&quot;true&quot; aria-hidden=&quot;false&quot; aria-label=&quot;Example home icon&quot;&gt;home&amp;lt;\/mat-icon&gt;\n  &amp;lt;\/button&gt; \n  &amp;lt;span class=&quot;space&quot;&gt;&amp;lt;\/span&gt;\n  &amp;lt;button class=&quot;buttons&quot; mat-button &#x5B;matMenuTriggerFor]=&quot;menu&quot;&gt;Courses&amp;lt;\/button&gt;\n  &amp;lt;mat-menu #menu=&quot;matMenu&quot;&gt;\n     &amp;lt;button mat-menu-item routerLink=&quot;\/data-science-course&quot;&gt;Data Science&amp;lt;\/button&gt;\n     &amp;lt;button mat-menu-item routerLink=&quot;\/devops-course&quot;&gt;DevOps&amp;lt;\/button&gt;\n  &amp;lt;\/mat-menu&gt;\n&amp;lt;\/mat-toolbar&gt;\n&amp;lt;router-outlet&gt;&amp;lt;\/router-outlet&gt;\n\n<\/pre><\/div>\n\n\n<p>In the above HTML code, <em>routerLink=\u201d\/\u201d<\/em> refers to the path to your first page URL i.e. <em>http:\/\/localhost:4200<\/em>.&nbsp;Next, <em>&lt;mat-icon&gt;<\/em> and <em>&lt;mat-menu&gt;<\/em> are components from Angular Materials, that represent various icons and menu options respectively. To use these components, import <em>MatIconModule<\/em> and <em>MatMenuModule<\/em> just like you did for <em>MatToolbarModule<\/em> from the <em>\u2018@angular\/material\u2019<\/em> directory, in your <em>app.module.ts<\/em> file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport { MatIconModule } from &#039;@angular\/material\/icon&#039;;\nimport { MatMenuModule } from &#039;@angular\/material\/menu&#039;;\n<\/pre><\/div>\n\n\n<p>Now, add <em>MatIconModule<\/em> and <em>MatMenuModule<\/em> in the <em>imports: [ ]<\/em> section located in the <em>app.module.ts<\/em> file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimports: &#x5B;\n    BrowserModule,\n    AppRoutingModule,\n    BrowserAnimationsModule,\n    MatToolbarModule,\n    MatIconModule,\n    MatMenuModule\n],\n<\/pre><\/div>\n\n\n<p>Proceeding further, write the following code in the <em>app.component.css<\/em> file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.space{\n    flex: 1 1 auto;\n} \n.home-space{\n    flex: 20 0 auto;\n} \n.buttons{\n    width: 100px;\n    height: 40px;\n    font-size: 15px;\n    border-radius: 10px;\n    border: 1px solid #113c89;\n    background-color: #ffcccc;\n    cursor: pointer;\n}\n.example-container {\n    background-color: Transparent;\n    background-repeat:no-repeat;\n    font-size: 35px;\n    height: 35px;\n    border: none;\n    cursor:pointer;\n    overflow: hidden;\n    outline:none;\n    color: white;\n}\n<\/pre><\/div>\n\n\n<p>The above CSS code will place and style the \u2018Homepage\u2019 icon and the \u2018Courses\u2019 menu option as per the provided criteria.&nbsp;<\/p>\n\n\n\n<p>Later, follow the same procedure as you did earlier to create routes for <em>data-science-course<\/em> and <em>devops-course<\/em> components.Import \u2018DataScienceCourseComponent\u2019 and \u2018DevopsCourseComponent\u2019 in the <em>app-routing.module.ts<\/em> file, as shown below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport { DataScienceCourseComponent } from &#039;.\/data-science-course\/data-science-course.component&#039;;\nimport { DevopsCourseComponent } from &#039;.\/devops-course\/devops-course.component&#039;;\n\n<\/pre><\/div>\n\n\n<p>In the same <em>app-routing.module.ts<\/em> file, create a path for <em>data-science-course<\/em> and <em>devops-course<\/em> components in the <em>Routes=[ ]<\/em> section.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst routes: Routes = &#x5B;\n  { path: &#039;first&#039;, component: FirstComponent },\n  { path: &#039;second&#039;, component: SecondComponent },\n  { path: &#039;data-science-course&#039;, component: DataScienceCourseComponent },\n  { path: &#039;devops-course&#039;, component: DevopsCourseComponent }\n];\n<\/pre><\/div>\n\n\n<p>The code will create routes for both components<em>.<\/em> You can now navigate through buttons.<\/p>\n\n\n\n<p>To implement it, execute your project by running the following command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nng serve -o\n\n<\/pre><\/div>\n\n\n<p>Click on either \u2018Data Science\u2019 or \u2018DevOps\u2019 buttons to navigate to their respective pages.<\/p>\n\n\n\n<p>Data Science Button:<\/p>\n\n\n\n<p>DevOps Button:<\/p>\n\n\n\n<p>Now, click on the \u2018Home\u2019 icon to redirect to your home page, as shown below:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"special-string-path\"><strong>Special String Path<\/strong><\/h2>\n\n\n\n<p>The Special String (**) redirects to your defined path, i.e., your home page if the requested URL doesn\u2019t match any of your defined paths or routes. You can add the special string path in the <em>Routes=[ ]<\/em> section, located in the <em>app-routing.module.ts<\/em> file of your project.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst routes: Routes = &#x5B;\n  { path: &#039;first&#039;, component: FirstComponent },\n  { path: &#039;second&#039;, component: SecondComponent },\n  { path: &#039;data-science-course&#039;, component: DataScienceCourseComponent },\n  { path: &#039;devops-course&#039;, component: DevopsCourseComponent },\n  { path: &#039;**&#039;, redirectTo: &#039;&#039;, pathMatch: &#039;full&#039; }\n];\n\n<\/pre><\/div>\n\n\n<p>In the above code snippet, you could see the defined paths in your project. Below is an example of implementing the special string path.&nbsp;<\/p>\n\n\n\n<p>First, execute your project using the \u2018ng serve -o\u2019 command. Then, type the following address in the URL section of your browser: http:\/\/localhost:4200\/third<\/p>\n\n\n\n<p>As you can see, the <em>third<\/em> component doesn\u2019t exist in your defined paths. Hence, your application will be redirected to your home page URL, which is: http:\/\/localhost:4200\/ <\/p>\n\n\n\n<p>Your browser will display the contents of your home page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>With this, I would like to sum up the article. I hope you are satisfied with my tutorial on all the basic fundamentals of Angular Routing and clear with all the hands-on demos of various sub-topics.&nbsp;<\/p>\n\n\n\n<p>As you read above, routing with SPAs is much easier and faster. The browser rendered only the necessary essentials.<\/p>\n\n\n\n<p>If you have any queries or feedback, drop us your comments in the comments section below and our experts will revert to you.<\/p>\n\n\n\n<p>If you wish to learn more about this concept, you can check out <a rel=\"noreferrer noopener\" href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/introduction-to-angularjs1\" target=\"_blank\">Great Learning Academy's Free Online Course on Introduction To AngularJS. <\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"frequently-asked-questions-on-angular\"><strong>Frequently Asked Questions on Angular <\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-do-i-start-angular-basics\"><strong>&nbsp;How do I start angular basics?<\/strong><\/h3>\n\n\n\n<p>Angular is a Typescript-based open-source framework for building front-end web applications. The best way to start angular basics is to get started with a basic course such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/introduction-to-angularjs1\">Introduction To AngularJS<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/angular7-for-beginners\">Angular7 for Beginners<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/angular7-for-intermediate-level\">Angular7 for Intermediate Level<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.mygreatlearning.com\/academy\/learn-for-free\/courses\/angular7-for-advanced-level\">Angular7 for Advanced Level<\/a><\/li>\n<\/ul>\n\n\n\n<p>Studies have shown that the number of skilled Angular developers is much lesser than the number of jobs available. So, make use of the above courses and start your preparations in Angular from scratch.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-are-the-basics-of-angular\"><strong>What are the basics of angular?<\/strong><\/h3>\n\n\n\n<p>Basics of Angular are typescript, directives, expressions, filters, modules, controllers Components, Modules and Decorators, all these basic learnings are essential to understand the higher versions of angular.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"is-it-worth-learning-angular-in-2020\"><strong>Is it worth learning angular in 2020?<\/strong><\/h3>\n\n\n\n<p>Yes, it\u2019s really worth learning angular in 2020-2021 as it is the most evolved framework.&nbsp; However, learning angular and its concepts may put off new developers as it is quite difficult when compared to other frameworks.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"which-angular-version-should-i-learn-as-a-beginner\"><strong>Which angular version should I learn as a beginner?<\/strong><\/h3>\n\n\n\n<p>As a beginner, you can choose the Angular 2 framework to learn, as it is written in typescript and supports mobile completely. The developer has choices for languages such as ES5, ES6, when they begin with angular 2.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"should-i-learn-angularjs-or-angular\"><strong>Should I learn AngularJS or angular?<\/strong><\/h3>\n\n\n\n<p>If you are a fresher, Yes, I suggest you go with Angular JS as it is fairly simple, less coding and an effective time-saving framework. With all these benefits, it is worth starting with angular js and eventually, you can take up higher versions of angular.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-is-angular-so-difficult\"><strong>Why is angular so difficult?<\/strong><\/h3>\n\n\n\n<p>&nbsp;It all depends on your JavaScript knowledge, so if you have a basic knowledge of JavaScript, it would be easy for you to sail through. But when you compare other JavaScript frameworks like react or vue, angular is quite difficult when it comes to code maintenance and readability.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"is-angular-dead\"><strong>Is angular dead?<\/strong><\/h3>\n\n\n\n<p>The developer survey says angular is the highest used framework after Node.js.So, no angular is not dead rather, the attention has just been diverted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"why-angular-is-so-popular\"><strong>Why angular is so popular?<\/strong><\/h3>\n\n\n\n<p>Angular is the platform that makes it easy to develop robust web applications and enables the secure binding of data to HTML elements. This is an end-to-end tooling platform to resolve the development challenges of developers and unites the declarative templates, dependency injection. This is the reason why angular is popular&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"is-angular-front-end-or-backend\"><strong>Is angular front end or backend?<\/strong><\/h3>\n\n\n\n<p>Angular is a JavaScript open-source front-end framework that is mainly used to develop single-page web applications.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"is-angular-better-than-mvc\"><strong>Is angular better than MVC?<\/strong><\/h3>\n\n\n\n<p>Yes, angular is better than MVC because of these below reasons:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Does not mix client and server code within the same file.<\/li>\n\n\n\n<li>Clear separation between client and server.<\/li>\n\n\n\n<li>Better automated testing.<\/li>\n\n\n\n<li>Easier UX\/UI design transition.<\/li>\n\n\n\n<li>Growing libraries and extensions.<\/li>\n\n\n\n<li>Team support.<\/li>\n<\/ul>\n\n\n\n<p><strong>Also Check:<\/strong> <a href=\"https:\/\/www.mygreatlearning.com\/blog\/top-angular-projects\/\">Top Angular Projects<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s kickstart our Angular Routing tutorial with its introduction. You can also take up a free Angular course that will help you learn more about the concept. Introduction to Angular Routing Navigating from one page to another page in a web application is known as Routing. Routing in Angular is called Angular Routing. Below is [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":25240,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25860],"tags":[],"content_type":[],"class_list":["post-25192","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Angular Tutorial for Beginners | What is Angular Routing<\/title>\n<meta name=\"description\" content=\"Angular Tutorial: In this tutorial, you will drive through all the essential concepts on Angular Routing. Routing with SPAs is much easier and faster.\" \/>\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.mygreatlearning.com\/blog\/angular-routing-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular Tutorial for Beginners - Everything you need to know\" \/>\n<meta property=\"og:description\" content=\"Angular Tutorial: In this tutorial, you will drive through all the essential concepts on Angular Routing. Routing with SPAs is much easier and faster.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Great Learning Blog: Free Resources what Matters to shape your Career!\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GreatLearningOfficial\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-02-22T05:47:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-03T05:54:34+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1254\" \/>\n\t<meta property=\"og:image:height\" content=\"837\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Great Learning Editorial Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Great_Learning\" \/>\n<meta name=\"twitter:site\" content=\"@Great_Learning\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Great Learning Editorial Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/\"},\"author\":{\"name\":\"Great Learning Editorial Team\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\"},\"headline\":\"Angular Tutorial for Beginners - Everything you need to know\",\"datePublished\":\"2021-02-22T05:47:00+00:00\",\"dateModified\":\"2024-09-03T05:54:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/\"},\"wordCount\":2719,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/iStock-901412996.jpg\",\"articleSection\":[\"IT\\\/Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/\",\"name\":\"Angular Tutorial for Beginners | What is Angular Routing\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/iStock-901412996.jpg\",\"datePublished\":\"2021-02-22T05:47:00+00:00\",\"dateModified\":\"2024-09-03T05:54:34+00:00\",\"description\":\"Angular Tutorial: In this tutorial, you will drive through all the essential concepts on Angular Routing. Routing with SPAs is much easier and faster.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/iStock-901412996.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/iStock-901412996.jpg\",\"width\":1254,\"height\":837,\"caption\":\"angular routing\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/angular-routing-tutorial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IT\\\/Software Development\",\"item\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/software\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Angular Tutorial for Beginners - Everything you need to know\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"name\":\"Great Learning Blog\",\"description\":\"Learn, Upskill &amp; Career Development Guide and Resources\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\"},\"alternateName\":\"Great Learning\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#organization\",\"name\":\"Great Learning\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/GL-Logo.jpg\",\"width\":900,\"height\":900,\"caption\":\"Great Learning\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/GreatLearningOfficial\\\/\",\"https:\\\/\\\/x.com\\\/Great_Learning\",\"https:\\\/\\\/www.instagram.com\\\/greatlearningofficial\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/in.pinterest.com\\\/greatlearning12\\\/\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/beaconelearning\\\/\"],\"description\":\"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.\",\"email\":\"info@mygreatlearning.com\",\"legalName\":\"Great Learning Education Services Pvt. Ltd\",\"foundingDate\":\"2013-11-29\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1001\",\"maxValue\":\"5000\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/#\\\/schema\\\/person\\\/6f993d1be4c584a335951e836f2656ad\",\"name\":\"Great Learning Editorial Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"contentUrl\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/wp-content\\\/uploads\\\/2022\\\/02\\\/unnamed.webp\",\"caption\":\"Great Learning Editorial Team\"},\"description\":\"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.\",\"sameAs\":[\"https:\\\/\\\/www.mygreatlearning.com\\\/\",\"https:\\\/\\\/in.linkedin.com\\\/school\\\/great-learning\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/Great_Learning\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCObs0kLIrDjX2LLSybqNaEA\"],\"award\":[\"Best EdTech Company of the Year 2024\",\"Education Economictimes Outstanding Education\\\/Edtech Solution Provider of the Year 2024\",\"Leading E-learning Platform 2024\"],\"url\":\"https:\\\/\\\/www.mygreatlearning.com\\\/blog\\\/author\\\/greatlearning\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Angular Tutorial for Beginners | What is Angular Routing","description":"Angular Tutorial: In this tutorial, you will drive through all the essential concepts on Angular Routing. Routing with SPAs is much easier and faster.","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.mygreatlearning.com\/blog\/angular-routing-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Angular Tutorial for Beginners - Everything you need to know","og_description":"Angular Tutorial: In this tutorial, you will drive through all the essential concepts on Angular Routing. Routing with SPAs is much easier and faster.","og_url":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/","og_site_name":"Great Learning Blog: Free Resources what Matters to shape your Career!","article_publisher":"https:\/\/www.facebook.com\/GreatLearningOfficial\/","article_published_time":"2021-02-22T05:47:00+00:00","article_modified_time":"2024-09-03T05:54:34+00:00","og_image":[{"width":1254,"height":837,"url":"http:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg","type":"image\/jpeg"}],"author":"Great Learning Editorial Team","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/Great_Learning","twitter_site":"@Great_Learning","twitter_misc":{"Written by":"Great Learning Editorial Team","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/"},"author":{"name":"Great Learning Editorial Team","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad"},"headline":"Angular Tutorial for Beginners - Everything you need to know","datePublished":"2021-02-22T05:47:00+00:00","dateModified":"2024-09-03T05:54:34+00:00","mainEntityOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/"},"wordCount":2719,"commentCount":0,"publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg","articleSection":["IT\/Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/","url":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/","name":"Angular Tutorial for Beginners | What is Angular Routing","isPartOf":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg","datePublished":"2021-02-22T05:47:00+00:00","dateModified":"2024-09-03T05:54:34+00:00","description":"Angular Tutorial: In this tutorial, you will drive through all the essential concepts on Angular Routing. Routing with SPAs is much easier and faster.","breadcrumb":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#primaryimage","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg","width":1254,"height":837,"caption":"angular routing"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mygreatlearning.com\/blog\/angular-routing-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/www.mygreatlearning.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IT\/Software Development","item":"https:\/\/www.mygreatlearning.com\/blog\/software\/"},{"@type":"ListItem","position":3,"name":"Angular Tutorial for Beginners - Everything you need to know"}]},{"@type":"WebSite","@id":"https:\/\/www.mygreatlearning.com\/blog\/#website","url":"https:\/\/www.mygreatlearning.com\/blog\/","name":"Great Learning Blog","description":"Learn, Upskill &amp; Career Development Guide and Resources","publisher":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization"},"alternateName":"Great Learning","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mygreatlearning.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mygreatlearning.com\/blog\/#organization","name":"Great Learning","url":"https:\/\/www.mygreatlearning.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/06\/GL-Logo.jpg","width":900,"height":900,"caption":"Great Learning"},"image":{"@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/GreatLearningOfficial\/","https:\/\/x.com\/Great_Learning","https:\/\/www.instagram.com\/greatlearningofficial\/","https:\/\/www.linkedin.com\/school\/great-learning\/","https:\/\/in.pinterest.com\/greatlearning12\/","https:\/\/www.youtube.com\/user\/beaconelearning\/"],"description":"Great Learning is a leading global ed-tech company for professional training and higher education. It offers comprehensive, industry-relevant, hands-on learning programs across various business, technology, and interdisciplinary domains driving the digital economy. These programs are developed and offered in collaboration with the world's foremost academic institutions.","email":"info@mygreatlearning.com","legalName":"Great Learning Education Services Pvt. Ltd","foundingDate":"2013-11-29","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1001","maxValue":"5000"}},{"@type":"Person","@id":"https:\/\/www.mygreatlearning.com\/blog\/#\/schema\/person\/6f993d1be4c584a335951e836f2656ad","name":"Great Learning Editorial Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","url":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","contentUrl":"https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2022\/02\/unnamed.webp","caption":"Great Learning Editorial Team"},"description":"The Great Learning Editorial Staff includes a dynamic team of subject matter experts, instructors, and education professionals who combine their deep industry knowledge with innovative teaching methods. Their mission is to provide learners with the skills and insights needed to excel in their careers, whether through upskilling, reskilling, or transitioning into new fields.","sameAs":["https:\/\/www.mygreatlearning.com\/","https:\/\/in.linkedin.com\/school\/great-learning\/","https:\/\/x.com\/https:\/\/twitter.com\/Great_Learning","https:\/\/www.youtube.com\/channel\/UCObs0kLIrDjX2LLSybqNaEA"],"award":["Best EdTech Company of the Year 2024","Education Economictimes Outstanding Education\/Edtech Solution Provider of the Year 2024","Leading E-learning Platform 2024"],"url":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"}]}},"uagb_featured_image_src":{"full":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg",1254,837,false],"thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996-150x150.jpg",150,150,true],"medium":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996-768x513.jpg",768,513,true],"large":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996-1024x683.jpg",1024,683,true],"1536x1536":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg",1254,837,false],"2048x2048":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg",1254,837,false],"web-stories-poster-portrait":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg",640,427,false],"web-stories-publisher-logo":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg",96,64,false],"web-stories-thumbnail":["https:\/\/www.mygreatlearning.com\/blog\/wp-content\/uploads\/2021\/02\/iStock-901412996.jpg",150,100,false]},"uagb_author_info":{"display_name":"Great Learning Editorial Team","author_link":"https:\/\/www.mygreatlearning.com\/blog\/author\/greatlearning\/"},"uagb_comment_info":0,"uagb_excerpt":"Let\u2019s kickstart our Angular Routing tutorial with its introduction. You can also take up a free Angular course that will help you learn more about the concept. Introduction to Angular Routing Navigating from one page to another page in a web application is known as Routing. Routing in Angular is called Angular Routing. Below is&hellip;","_links":{"self":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/25192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/comments?post=25192"}],"version-history":[{"count":62,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/25192\/revisions"}],"predecessor-version":[{"id":112141,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/posts\/25192\/revisions\/112141"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media\/25240"}],"wp:attachment":[{"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/media?parent=25192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/categories?post=25192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/tags?post=25192"},{"taxonomy":"content_type","embeddable":true,"href":"https:\/\/www.mygreatlearning.com\/blog\/wp-json\/wp\/v2\/content_type?post=25192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}