This content originally appeared on DEV Community and was authored by loizenai
Django + Angular 6 example | Django Rest Framework + MySQL CRUD example – Part 3: Angular Client
This tutorial is part 3 of Django-Angular-MySQL series. Today, we will create Angular Client to make HTTP request & receive response from Django Server.
>> Part 1: Overview
>> Part 2: Django Server
Video
Angular Client Overview
Goal
The image below shows overview about Angular Components that we will create:
Project Structure
We have:
- 4 components: customers-list, customer-details, create-customer, search-customer.
- 3 modules: FormsModule, HttpClientModule, AppRoutingModule.
- customer.ts: class Customer (id, firstName, lastName)
- customer.service.ts: Service for Http Client methods
- app-routing.module.ts: Routing configuration
Setup Angular Project
Create Angular Project
Run command: ng new AngularDjango
.
Create Service & Components
On Project folder, run commands below:
- ng g s customer
- ng g c create-customer
- ng g c customer-details
- ng g c customers-list
- ng g c search-customers
On each Component selector, delete app-
prefix, then change tslint.json rules
- "component-selector"
to false.
Implement Angular Client App
Data Model
Create new file named customer.ts:
export class Customer {
id: number;
name: string;
age: number;
active: boolean;
}
Data Service
More at:
Django + Angular 6 example | Django Rest Framework + MySQL CRUD example – Part 3: Angular Client
This content originally appeared on DEV Community and was authored by loizenai
loizenai | Sciencx (2021-04-19T17:25:28+00:00) Django + Angular 6 example | Django Rest Framework + MySQL CRUD example – Part 3: Angular Client. Retrieved from https://www.scien.cx/2021/04/19/django-angular-6-example-django-rest-framework-mysql-crud-example-part-3-angular-client/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.