LogoLogo
  • Introduction
  • Backend
    • Creating a MongoDB Database
    • Environment Variables
    • Configuring the Mailing Service
    • Seeding the Database
    • Starting the Backend
  • Frontend
    • Starting the Frontend
  • Book Module Tutorial
    • Introduction
    • Backend
      • Create Model
      • Create Service
      • Create Route
      • Test using Postman
    • Frontend
      • Introduction
      • File Structure
      • Defining Concepts
      • Display App in Dashboard
      • Create Module
      • Create Book List Component
      • Create Main Component
      • Create Service
      • Display Book List
      • Add a Book
        • Update Service
        • Create Component
        • Final Code Review
      • Delete a Book
        • Update Service
        • Update Component
        • Final Code Review
      • Conclusion
  • Resources
  • Beginner
  • Advanced
  • Recommended Extensions for Visual Studio Code
  • Troubleshooting
    • Troubleshooting
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Book Module Tutorial
  2. Frontend

Create Book List Component

We need to generate a component for our application. In our console, navigate to the book management folder that we have created earlier. Your path should look similar to:

/smuportal-frontend/src/app/applications/book-management-system

Once reached, we are ready to create our component. Angular allows us to generate a component with a simple command:

ng generate component list-books

We only need to define our component in the module we created. Your book management system module should become the following:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from "@angular/router";
import { ListBooksComponent } from './list-books/list-books.component';


const routes: Routes = [
  {
    path: "list",
    component: ListBooksComponent
  },
];

@NgModule({
  declarations: [],
  declarations: [ListBooksComponent],
  imports: [
    CommonModule
  ]
})
export class BookManagementSystemModule { }

Finally, we create a new file "index.ts" in the list-books folder and add the following line:

export * from "./list-books.component"
PreviousCreate ModuleNextCreate Main Component

Last updated 4 years ago

Was this helpful?