Angular 9 Tutorial For Beginners #58- Services

preview_player
Показать описание
Angular 9 Tutorial For Beginners #58- Services in Angular, Angular services tutorials, services in Angular, Angular services tutorials in Angular, Angular 9 services tutorials in Angular, Angular tutorial learn services tutorials in Angular, angular 9 services tutorials in Angular, angular get set reset values from services tutorials In Angular 6,7,8, 9, angular 8 example,

Angular 9 tutorial for beginners, angular 9 crash course, angular 9 tutorial for beginners step by step, angular tutorial for beginners 2020, angular tutorial 2020, arc tutorial angular, angular code examples, angular for freshers, angular tutorial for experienced, angular introduction, angular version history, angular full tutorial series, best angular tutorial.

Install bootstrap angular tutorial, Learn how to install Bootstrap in Angular 9 app. In this course you will learn how to create small, medium, large applications with Angular 9 in this development tutorial.

Angular 9 Full Tutorial Playlist
Рекомендации по теме
Комментарии
Автор

Angular 9 Tutorial For Beginners #58- Services

- Services allow us to create reusable common shared functionality between various models and components
- Services are singleton
- Services are injected into the application using DI mechanism
- Services are commonly used for making HTTP requests to our endpoints to request and receive the response
- A service can have value, methods, or a combination of both!
- Unlike components, services need not be included in your modules
- We can create any number of services
- Importing and Injecting services into components are called dependency injection
- Services are injected at runtime, this way code becomes highly efficient and easy to maintain
- ng generate service <servicename>
- We can generate the service in any of the folder we want
- but best practice is always to keep all services related into modules
- @Injectable decorator inform to angular that we can inject it into components
- The service is ProvidedIn "root" will be available across the application
- can be injected into any component
- Make the service as public in the constructor so that you can call the service method from template(html) as well.

Example:

Contacts Module
- Create Contact
- View Contact
- Edit Contact
- Delete Contact
Contact Services
- HTTP
- Processing Data
- Cleaning Data


services.ts


@Injectable({
providedIn: 'root'
})
export class ContactsService {
constructor() { }
getContacts()
{
const contactList=[
{ContactId:1, ContactName:'James'},
{ContactId:2, ContactName:'Clark'},
{ContactId:3, ContactName:'Ruby'},
{ContactId:4, ContactName:'Jack'}
]

return contactList;
}

callingFromTemplate()
{
console.log('calling from template');
}
}

component.ts

import { ContactsService } from '../contacts.service';

@Component({
selector: 'app-contacts',
templateUrl: './contacts.component.html',
styleUrls:
})
export class ContactsComponent implements OnInit {
_contacts = [];
constructor(private contactservice: ContactsService) {}
ngOnInit(): void {
this._contacts =
}
}

component.html

<h4>List Of Contacts</h4>
<ul>
<li *ngFor="let contact of _contacts">
{{contact.ContactId}} - {{contact.ContactName}}
</li>
</ul>
<a From Template</a>

sreenuksr
Автор

This is how you teach❤️.
I have seen the video from Udemy, they are good but it was easy for me to understand by your explanation .
Thank you.
Finally understood what Service is.

mdshabbiralam
Автор

Really Really great channel for angular.
Your way of explaining the concept is another level.
I'll definitely suggest this channel to all my friends.
Appreciate your hard work.

themysteryman-ej
Автор

The quality of this content is simply amazing 👏🏻 learning so much, thankyou!

kiranshelar
Автор

thanks a lot, this clears the questions I had asked earlier... as usual simple and straight to the point. thanks.. missing tutorials 56 and 57

jacksm
Автор

Your explanation is very clear bro, thanks a lot for the Tutorials 👏
Waiting for CRUD operation videos in Angular...

rajujeelaga
Автор

You are more than any teaching classes..

omkarmore
Автор

Hi sir. I'm a newbie in programming. Really the best tutorial so far I've been watching. The way you explain is very easy to understand compared to Udemy. Currently, I've been assigned in a project on my work using Angular 10 sir. I hope that you can provide more tutorials on that. I've been watching the tutorial for Angular 10 that you posted. So excited to know more about programming and from all your tutorials.

Greetings from Malaysia ❤️

Nadh_Zulki
Автор

This channel deserves an award! Like if you agree

AfolabiJude
Автор

ur Teaching is on another level, Im subscribing

Sn-kdty
Автор

Really Your tutorial is great for everyone.Please share your notes which is created while learing .

chiragsolanki
Автор

Thanks Sridhar. Awesome explanation! I am enjoying it. Thank you for taking your precious time. I will follow you all the way!

amanuellebassi
Автор

Thank you man, how do I select the item to display from the list or from the array ?

mohamedibrahimabdulghani
Автор

Very nice tutorial ❤ and very useful

sarojKumar-dvdy
Автор

Thank you for this tutorial series 🙏. It's help's alot.

rahulchopkar
Автор

Great video! I wish I live to see people calling '@' just "at" and not "at the rate".

kalyanchatterjee
Автор

I am little confused as we can use services as shared service which we can use in multiple components using dependency injection then can we use the same service to publish and subscribe.

shirish
Автор

Pls how do I create a service for url.. Assuming I want to move the url from my source code to a centralized location (service) for easy iteration and testing

overflowingworld
Автор

I have a doubt. If we have three modules a, b, c and some of them use a service that imports inside It something (maybe http), where do we import that http that uses oír service?

antonioubedamontero
Автор

hello sir, recently i had an interview with a company, i wanted to be in React, but they have selected me for angular? I have learned React, but have no idea about Angular. Though they are willing to give me 15 days to learn Angular? My query is is Angular Good as compared with React, as companies have started shifting to React due to its simplicity. Please reply

ShishupalSingh-zbsk