How to Create Admin in Angular by Rajib Gupta
Author - @Rajibgupta
Documentation
- First we have to create admin module:
ng g m admin --routing
- --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
- And for showing admin list we have to create one more component
ng g c admin/list
-
**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},
]; -
After that go to the app.module.ts file and define admin module inside that.
import { AdminModule } from './admin/admin.module';
imports: [
AdminModule
], -
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>
-
And lastly we need for run our project by serving.
ng serve
Thank you.
Top comments (0)