DEV Community

Cover image for Create a Admin Module in Angular
Rajib Gupta
Rajib Gupta

Posted on

Create a Admin Module in Angular

How to Create Admin in Angular by Rajib Gupta

Author - @Rajibgupta

Documentation

Documentation

  1. First we have to create admin module:

ng g m admin --routing

  1. --routing generates our routing module for admin automatically.

with the help of router module we can pass our admin components. Which will only access by our admin.
After the creation of admin module we have to create our component like

ng g c admin/login

  1. And for showing admin list we have to create one more component

ng g c admin/list

  1. **Then we have to define our login component and list component inside our admin-routing.module.ts file.

    import { ListComponent } from './list/list.component';

    import { LoginComponent } from './login/login.component';

    const routes: Routes = [
    {path:"login",component:LoginComponent},
    {path:"list",component:ListComponent},
    ];

  2. After that go to the app.module.ts file and define admin module inside that.

    import { AdminModule } from './admin/admin.module';
    imports: [
    AdminModule
    ],

  3. Then, we need to call our login and list component inside our parent component or app.component.html file.

    <div class="container">
    <ul>
    <li><a routerLink="login">Login</a></li>
    <li><a routerLink="list">List</a></li>
    </ul>

    <router-outlet></router-outlet>

    </div>

  4. And lastly we need for run our project by serving.

    ng serve

Thank you.

Top comments (0)