{"id":504,"date":"2019-09-03T10:20:05","date_gmt":"2019-09-03T10:20:05","guid":{"rendered":"https:\/\/docs.theironnetwork.org\/vuely\/?page_id=504"},"modified":"2019-09-25T03:38:35","modified_gmt":"2019-09-25T03:38:35","slug":"adding-deleting-menu-component","status":"publish","type":"page","link":"https:\/\/docs.theironnetwork.org\/vuely\/adding-deleting-menu-component\/","title":{"rendered":"Adding\/Deleting Menu &#038; Component"},"content":{"rendered":"\n<h6>Adding a new menu &amp; component<\/h6>\n\n\n\n<p>We will help you in creating a new component. Follow the steps below to add a new component. We will add a test component in the template:<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Open the <code>src-&gt;app<\/code> folder in the terminal or command prompt &amp; run the following command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ng generate module test --routing<\/pre>\n\n\n\n<p>It will create a module &amp; its routing file inside the test folder.<\/p>\n\n\n\n<p><strong>Step 2: <\/strong>Now run the following command in the same app folder like you did in the above step<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ng generate component test\/test1<\/pre>\n\n\n\n<p>It will create the test1 component in the test folder. After completing these two steps, when you will open the test folder, It will looks like:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/test-folder.png\"><img loading=\"lazy\" width=\"456\" height=\"83\" src=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/test-folder.png\" alt=\"\" class=\"wp-image-507\" srcset=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/test-folder.png 456w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/test-folder-300x55.png 300w\" sizes=\"(max-width: 456px) 100vw, 456px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>It contains the module, its routing file &amp; the component folder.<\/p>\n\n\n\n<p><strong>Step 3:<\/strong> Now open the <code>test-routing.module.ts<\/code> file to add the route of the newly created component <code>test1<\/code>. You need to import the component and then define the path of the component. Like given in the example below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { NgModule } from '@angular\/core';<br>import { Routes, RouterModule } from '@angular\/router';<br>import { Test1Component } from '.\/test1\/test1.component'; \/\/ Import the component<br> <br>const routes: Routes = [<br> \/\/ Define the path of the component test1<br> {<br> path : '',<br> component : Test1Component<br> }<br>];<br> <br>@NgModule({<br>  imports: [RouterModule.forChild(routes)],<br>  exports: [RouterModule]<br>})<br>export class TestRoutingModule { }<\/pre>\n\n\n\n<p><strong>Step 4: <\/strong>Open the <code>src-&gt;app-&gt;app-routing.ts<\/code> file and add the route of the test module in the children array. See the code below for the reference:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">children: [<br>         ...<br>         \/\/ Newly added route of the test module<br>        { <br>            path: 'test',<br>            loadChildren : '.\/test\/test.module#TestModule'<br>         } <br>]<\/pre>\n\n\n\n<p><strong>Step 5: <\/strong>Now add this component in the sidebar menu. Open the <code>src-&gt;app-&gt;Core-&gt;MenuItems-&gt;MenuItems.ts<\/code> file and add the component in the <code>MENUITEMS<\/code>array. Like we have added in the below example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">const MENUITEMS = [<br>  ...<br>  \/\/ Added Component<br>   {<br>      name : 'Test',<br>      type : 'sub',<br>      class: 'group-title',<br>      icon : '',<br>      isOpen:true,<br>      children : [<br>         {<br>            state: 'test',<br>            name: 'Test 1',<br>            type: 'link',<br>            class: 'nav-item',<br>            icon: 'description'<br>         }<br>      ]<br>   }<br>];<\/pre>\n\n\n\n<p>Now you have completed all the steps of adding the component in the template &amp; the sidebar menu. Save the file and open the browser, you will see your newly added component in the sidebar. Have a look at the screenshot below to check how your component is added in the template:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/testpage.png\"><img loading=\"lazy\" width=\"1024\" height=\"523\" src=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/testpage-1024x523.png\" alt=\"\" class=\"wp-image-505\" srcset=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/testpage-1024x523.png 1024w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/testpage-300x153.png 300w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/testpage-768x392.png 768w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/testpage.png 1305w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n\n<h5 id=\"deleting-a-menu-and-component-from-the-menu-list\">Deleting a menu &amp; component from the menu list<a href=\"#deleting-a-menu-and-component-from-the-menu-list\"><\/a><\/h5>\n\n\n\n<p>We will help you in deleting a menu &amp; its component from the menu list by listing down the steps needed to delete. Please follow the steps described below, We will take an example by deleting the test1 component &amp; TEST menu from the menu list which we have created in the above part:<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Firstly, open the <code>src-&gt;app-&gt;test-&gt;test.module.ts<\/code> file and remove the <code>test1<\/code> component <code>import statement<\/code> &amp; its declaration from the <code>declarations<\/code> array in the file. Like we have removed the commented lines from the given code example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { NgModule } from '@angular\/core';<br>import { CommonModule } from '@angular\/common';<br> <br>import { TestRoutingModule } from '.\/test-routing.module';<br>\/\/import { Test1Component } from '.\/test1\/test1.component'; \/\/ Delete this import statement<br> <br>@NgModule({<br>  declarations: [<br>  \/\/Test1Component \/\/ Delete this declaration<br>  ],<br>  imports: [<br>    CommonModule,<br>    TestRoutingModule<br>  ]<br>})<br>export class TestModule { }<\/pre>\n\n\n\n<p><strong>Step 2: <\/strong>Now open the <code>src-&gt;app-&gt;test-&gt;test-routing.module.ts<\/code> file and remove the <code>import statement<\/code>  of <code>test1<\/code> component &amp; its route from the <code>routes<\/code> array. Like we have removed the commented lines from the given code example.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import { NgModule } from '@angular\/core';<br>import { Routes, RouterModule } from '@angular\/router';<br>\/\/import { Test1Component } from '.\/test1\/test1.component'; \/\/ Delete this import statement<br> <br>const routes: Routes = [<br> \/\/ Delete this route<br> \/\/ {<br> \/\/  path : '',<br> \/\/  component : Test1Component<br> \/\/ }<br>];<br> <br>@NgModule({<br>  imports: [RouterModule.forChild(routes)],<br>  exports: [RouterModule]<br>})<br>export class TestRoutingModule { }<\/pre>\n\n\n\n<p><strong>Step 3: <\/strong>Now delete the <code>test1<\/code> component folder manually from the <code>src-&gt;app-&gt;test<\/code> folder.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/del-test.png\"><img loading=\"lazy\" width=\"478\" height=\"142\" src=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/del-test.png\" alt=\"\" class=\"wp-image-506\" srcset=\"https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/del-test.png 478w, https:\/\/docs.theironnetwork.org\/vuely\/wp-content\/uploads\/sites\/2\/2019\/09\/del-test-300x89.png 300w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/a><\/figure><\/div>\n\n\n\n<p><strong>Step 4: <\/strong>Open the <code>src-&gt;app-&gt;Core-&gt;MenuItems-&gt;MenuItems.ts<\/code> file and remove the component from the <code>MENUITEMS<\/code> array. Like we have removed the commented lines from the given code example.MenuItems.ts<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">const MENUITEMS = [<br>  ...<br>  \/\/ Deleted\/Removed Component<br>   \/\/ {<br>   \/\/    name : 'Test',<br>   \/\/    type : 'sub',<br>   \/\/    class: 'group-title',<br>   \/\/    icon : '',<br>   \/\/    isOpen:true,<br>   \/\/    children : [<br>   \/\/       {<br>   \/\/          state: 'test',<br>   \/\/          name: 'Test 1',<br>   \/\/          type: 'link',<br>   \/\/          class: 'nav-item',<br>   \/\/          icon: 'description'<br>   \/\/       }<br>   \/\/    ]<br>   \/\/ }<br>];<\/pre>\n\n\n\n<p>That&#8217;s it, now you have completed all the steps to delete a menu from the menu list and its component from the app. Save the file and open the browser, now you will see that your template does not contains your deleted component anymore.<\/p>\n<div class=\"pld-like-dislike-wrap pld-template-1\">\n    <div class=\"pld-like-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-like-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"504\" data-trigger-type=\"like\" data-restriction=\"cookie\" data-ip-check=\"0\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-up\"><\/i>\n                    <\/a>\n    <span class=\"pld-like-count-wrap pld-count-wrap\">    <\/span>\n<\/div><div class=\"pld-dislike-wrap  pld-common-wrap\">\n    <a href=\"javascript:void(0);\" class=\"pld-dislike-trigger pld-like-dislike-trigger \" title=\"\" data-post-id=\"504\" data-trigger-type=\"dislike\" data-ip-check=\"0\" data-restriction=\"cookie\" data-user-check=\"1\">\n                        <i class=\"fas fa-thumbs-down\"><\/i>\n                    <\/a>\n    <span class=\"pld-dislike-count-wrap pld-count-wrap\"><\/span>\n<\/div><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Adding a new menu &amp; component We will help you in creating a new component. Follow the steps below to add a new component. We will add a test component in the template: Step 1: Open the src-&gt;app folder in the terminal or command prompt &amp; run the following command: ng generate module test &#8211;routing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":57,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/504"}],"collection":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/comments?post=504"}],"version-history":[{"count":3,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/504\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/pages\/504\/revisions\/723"}],"wp:attachment":[{"href":"https:\/\/docs.theironnetwork.org\/vuely\/wp-json\/wp\/v2\/media?parent=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}