DotNet-301-ElevenNoteAngular
  • Introduction
  • Part 1: Setup with the Angular CLI
  • Part 2: Building out the Header Component
  • Part 3: Sprucing up the Header Using Material
  • Part 4: Building the Registration Page with Reactive Angular Form
  • Part 5: Routing with Angular Router
  • Part 6: Design Break: Fonts
  • Part 7: Communicating with Web API with Auth Service
  • Part 8: Logging in with a token
  • Part 9: Routing After a Request
  • Part 10: Log In page Challenge
  • Part 11: Building the Note Index page
  • Part 12: Creating Note C.r.u.d. — Create
  • Part 13: Creating Note c.R.u.d. — Read
  • Part 14: Creating Note c.r.U.d. — Update
  • Part 15: Creating Note c.r.u.D. — Delete
  • Part 16: Protecting our views with Guards
Powered by GitBook
On this page
  • Step 1. Note Service
  • Step 2. Setting up the form in the Note Delete Controller
  • Step 3. Creating the HTML for the Note Create

Part 15: Creating Note c.r.u.D. — Delete

PreviousPart 14: Creating Note c.r.U.d. — UpdateNextPart 16: Protecting our views with Guards

Last updated 7 years ago

The last of the crud, to create the Delete . Using the Angular CLI create the note-delete component.

Type:

ng g c components/note/note-delete --no-spec

Step 1. Note Service

Like always we will start at the NoteService, we will create a deleteNote(:id: number) method, and we will pass in the id of the note that we would like to get rid of. Based on our docks .

Let’s add the path to this while we are at it, in the app.modules.ts file

Step 2. Setting up the form in the Note Delete Controller

In our controller, there are going to be similarities between our note-details and note-update, and that’s getting the id from the params of the URL

In our constructor we will just copy and paste.

What will be new is how we delete the note. We are going to do it through a button click action, so we will need a onDelete() method that calls our deleteNote() service method.

Step 3. Creating the HTML for the Note Create

Let’s present the data to our users, which looks just like our note-details component view, so another copy and paste job.

Step 4. Finishing the path in the NoteIndex

Next we will add the routerLink to the delete icon

action
here
Logo Title Text 1
Logo Title Text 1
Logo Title Text 1
Logo Title Text 1
Logo Title Text 1
Logo Title Text 1