2016-10-23 13:58:20

How to set properties in subscribed services in Angular 2

If you are familiar with AngularJS you may know that sometimes we need to use $apply or $digest to binding values but now in Angular 2 there is no apply, digest or scope concepts to use.

Ladies and Gentlemans, NgZone ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘

 Usage example:



import {Component, Output, EventEmitter, NgZone} from "@angular/core";

import {WebService} from "../services/webservice";
import {CONSTS} from "../CONSTS";
@Component({ templateUrl:"./home.template.html" })
export class HomeComponent{
public userInfo : EventEmitter<any> = new EventEmitter<any>();

//User Model public user : User = new User(); constructor(public webService:WebService,private zone: NgZone){
this.userInfo.subscribe((params)=> =>{ =;

it's a piece of cake, Happy Coding :D

Tags Cloud

Angular 2







Angular JS

subscribe service