Hi Team
I need some help in below instruction to create a phone book in Angular.
// instructions
"Your goal is to create a simple form at the top that allows the user to enter in a first name, last name, and phone number and there should be a submit button. Once the submit button is pressed, the information should be displayed in a list below (automatically sorted by last name) along with all the previous information that was entered" "First name = Coder
Last name = Byte
Phone = 8885559999"
Tuhin PaulPosted Mar 1, 2023, 3:29 AM
Hi Gcobani,
It seems like this is an assignment question. Anyways see below for the steps to create a phone book in Angular
Step 1: Set up a new Angular project using the Angular CLI by running the command ng new phone-book in the terminal.
Step 2: Create a new component for the phone book form by running the command ng generate component phone-book-form.
Step 3: In the phone-book-form.component.html file, create a form that includes inputs for the first name, last name, and phone number, as well as a submit button. Here's an example:
Step 4: In the phone-book-form.component.ts file, define properties for the firstName, lastName, and phoneNumber inputs and create a method called submit() that adds the entered information to an array of contacts. Here's an example:
Step 5: Create a new component for the phone book list by running the command ng generate component phone-book-list.
Step 6: In the phone-book-list.component.html file, use an *ngFor directive to display the list of contacts. Here's an example:
We have used sortByName pipe for sorting the contact list by the last name.
Step 7: In the phone-book-list.component.ts file, define an input property called contacts and create a sortByName pipe that sorts the contacts by last name. Here's an example:
Step 8: In the app.component.html file, add the phone book form and list components to the page. Here's an example:
Step 9: Test the application by running