Skip to main content

Posts

Showing posts with the label What is NgZone run outside Angular 2?

What would be a good use for NgZone Service?

Angular 2 runs inside of its own special zone called NgZone and this special zone extends the basic functionality of a zone to facilitate change detection. It is Running inside a zone allows to detect when asynchronous tasks. If you change or update your internal application code or view and it is detecting the applications changes with help of NgZone. Example 1 -  We use NgZone to trigger change detection as import { Component, NgZone} from '@angular/core' ; import { CommonModule } from '@angular/common' ; import { HttpModule, Http } from '@angular/http' ; import { UserService } from '../service/user.service' ; import { AppGlobals } from '../../shared/app.globals' ; @ Component({ selector : 'user' , templateUrl : './user.component.html' , styleUrls : [ './user.component.css' ], providers : [UserService, AppGlobals] }) export class UserComponent { //USERS DECLARATIONS. ...

What is NgZone run outside Angular 2?

NgZone Run Outside -  Execute the “fn” functions asynchronously in Angular’s parent zone and returns value returned by the function. Syntax - NgZone.runOutsideAngular(fn:() => any): any Example as, import { Component, NgZone} from '@angular/core' ; import { CommonModule } from '@angular/common' ; import { HttpModule, Http } from '@angular/http' ; import { UserService } from '../service/user.service' ; import { AppGlobals } from '../../shared/app.globals' ; @ Component({ selector : 'user' , templateUrl : './user.component.html' , styleUrls : [ './user.component.css' ], providers : [UserService, AppGlobals] }) export class UserComponent { //USERS DECLARATIONS. users = []; label: string ; counter: number = 0 ; //USER COMPONENT CONSTRUCTOR. constructor ( private _userService: UserService , private _global: AppGlobals , private _ngZ...

What are Zones? What is Change Detection? What is NgZone run outside ?

What are Zones?  What is NgZone in Angular 2? Angular 2 runs inside of its own special zone called NgZone and this special zone extends the basic functionality of a zone to facilitate change detection. It is Running inside a zone allows to detect when asynchronous tasks. If you change or update your internal application code or view and it is detecting the applications changes with help of NgZone. Stayed Informed -  69 Best Angular 2 Interview Questions and Answers Application state change by following things as, 1.      Events – Looks like as click, change, input, submit, etc. 2.      XMLHttpRequests – It’s occurs when we fetch data from a remote service. 3.      Timers – when you use timer methods such as setTimeout (), setInterval (), etc. What is Change Detection? Angular 2 runs inside of its own special zone called NgZone and this special zone extends the basic functionality o...