Learn jQuery from the Best Tutors
Search in
Lesson Posted on 25/09/2017 Learn jQuery
Dependency Injection in Angular 2
Ranjan Panda
I am .Net Trainer with more than 6 years Industry experience in Microsoft .net technologies, Expertise...
Dependency injection is a way to supply a new instance of a class with the fully-formed dependencies it requires. Most dependencies are services. Angular uses dependency injection to provide new components with the services they need.
Angular can tell which services a component needs by looking at the types of its constructor parameters. For example, the constructor of your HeroListComponent
needs a HeroService
:
Sample Code-
constructor(private service: HeroService) { }
When Angular creates a component, it first asks an injector for the services that the component requires.
An injector maintains a container of service instances that it has previously created. If a requested service instance is not in the container, the injector makes one and adds it to the container before returning the service to Angular. When all requested services have been resolved and returned, Angular can call the component's constructor with those services as arguments. This is dependency injection.
The process of HeroService
injection looks a bit like this:
If the injector doesn't have a HeroService
, how does it know how to make one?
In brief, you must have previously registered a provider of the HeroService
with the injector. A provider is something that can create or return a service, typically the service class itself.
You can register providers in modules or in components.
In general, add providers to the root module so that the same instance of a service is available everywhere.
BackendService,
HeroService,
Logger
],
Alternatively, register at a component level in the providers
property of the @Component
metadata:
selector: 'hero-list', templateUrl: './hero-list.component.html', providers: [ HeroService ]})
Registering at a component level means you get a new instance of the service with each new instance of that component.
Points to remember about dependency injection:
Dependency injection is wired into the Angular framework and used everywhere.
The injector is the main mechanism.
A provider is a recipe for creating a service.
Register providers with injectors.
Lesson Posted on 25/09/2017 Learn jQuery
Mark And Sweep Algorithm in Javascript Memory Management
Ranjan Panda
I am .Net Trainer with more than 6 years Industry experience in Microsoft .net technologies, Expertise...
This algorithm assumes the knowledge of a set of objects called roots (In JavaScript, the root is the global object). Periodically, the garbage-collector will start from these roots, find all objects that are referenced from these roots, then all objects referenced from these, etc. Starting from the roots, the garbage collector will thus find all reachableobjects and collect all non-reachable objects.
This algorithm is better than the previous one since "an object has zero reference" leads to this object being unreachable. The opposite is not true as we have seen with cycles.
As of 2012, all modern browsers ship a mark-and-sweep garbage-collector. All improvements made in the field of JavaScript garbage collection (generational/incremental/concurrent/parallel garbage collection) over the last few years are implementation improvements of this algorithm, but not improvements over the garbage collection algorithm itself nor its reduction of the definition of when "an object is not needed anymore".
read lessLesson Posted on 30/05/2017 Learn jQuery
jquery add class,remove class,toggle class video
Mohit Gaur
Currently I am working in Sphinx World Biz Ltd. company. I have more than 5 years Experience in Web Designing,...
Learn jQuery from the Best Tutors
Lesson Posted on 13/05/2017 Learn jQuery
Mohit Gaur
Currently I am working in Sphinx World Biz Ltd. company. I have more than 5 years Experience in Web Designing,...
Lesson Posted on 13/05/2017 Learn jQuery
Mohit Gaur
Currently I am working in Sphinx World Biz Ltd. company. I have more than 5 years Experience in Web Designing,...
Lesson Posted on 13/05/2017 Learn jQuery
Mohit Gaur
Currently I am working in Sphinx World Biz Ltd. company. I have more than 5 years Experience in Web Designing,...
Learn jQuery from the Best Tutors
Lesson Posted on 03/05/2017 Learn jQuery
Mohit Gaur
Currently I am working in Sphinx World Biz Ltd. company. I have more than 5 years Experience in Web Designing,...
Lesson Posted on 03/05/2017 Learn jQuery
Jquery Tab Create By Me In Jquery
Mohit Gaur
Currently I am working in Sphinx World Biz Ltd. company. I have more than 5 years Experience in Web Designing,...
Answered on 24/02/2017 Learn jQuery
Shabana p.
Trainer
Learn jQuery from the Best Tutors
Lesson Posted on 19/01/2017 Learn jQuery
what is jquery and why we use it ?
Suraj Ghosi
My skills asp.net , asp.net mvc , mvc+web api , javascript , jquery, html5 ,css3 , bootstrap, sql server...
Jquery : - it is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development
Advanctage of Jquery :-
I hope this lesson increase your knowledge about jquery basic .
Let us know if you have any concern.
read lessUrbanPro.com helps you to connect with the best jQuery Training in India. Post Your Requirement today and get connected.
Ask a Question
The best tutors for jQuery Classes are on UrbanPro
The best Tutors for jQuery Classes are on UrbanPro