angular2-observables

How to make nested Observable calls in Angular2

谁说胖子不能爱 提交于 2019-11-26 13:57:28
问题 I am having some troubles making nested Observable calls. By that I mean a call to a http service that retrieve a user, then getting the id from the user to make another http call, and finally render the results on screen. 1) HTTP GET 1 : get the User 2) HTTP GET 2: get the User's preferences passing a unique identifier as a parameter This translates into the following code in component Blah.ts : version 1 - this code does not display anything ngOnInit() { this.userService.getUser() .flatMap

Angular 2+ and Observables: Can't bind to 'ngModel' since it isn't a known property of 'select'

柔情痞子 提交于 2019-11-26 11:25:05
EDIT: Updated Plunkr: http://plnkr.co/edit/fQ7P9KPjMxb5NAhccYIq?p=preview this part works: <div *ngFor="let entry of entries | async"> Label: {{ entry.label }}<br> Value: {{ entry.value }} </div> but I've problems with the select box, the error message is: Can't bind to 'ngModel' since it isn't a known property of 'select' The whole Component: //our root app component import {Component} from '@angular/core'; import {NgFor} from '@angular/common'; import {HTTP_PROVIDERS, Http} from '@angular/http'; import 'rxjs/Rx'; import {Observable} from 'rxjs/Rx'; @Component({ selector: 'my-app', providers:

Subject vs BehaviorSubject vs ReplaySubject in Angular

…衆ロ難τιáo~ 提交于 2019-11-26 08:43:01
问题 I\'ve been looking to understand those 3: Subject , Behavior subject and Replay subject . I would like to use them and know when and why, what are the benefits of using them and although I\'ve read the documentation, watched tutorials and searched google I\'ve failed to make any sense of this. So what are their purpose? A real-world case would be most appreciated it does not have to even code. I would prefer a clean explanation not just \"a+b => c you are subscribed to ....\" Thank you 回答1:

take(1) vs first()

萝らか妹 提交于 2019-11-26 06:05:27
问题 I found a few implementation of AuthGuard s that use take(1) . In my project, I used first() . Do both work the same way? import \'rxjs/add/operator/map\'; import \'rxjs/add/operator/first\'; import { Observable } from \'rxjs/Observable\'; import { Injectable } from \'@angular/core\'; import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from \'@angular/router\'; import { AngularFire } from \'angularfire2\'; @Injectable() export class AuthGuard implements CanActivate {

Angular 2+ and Observables: Can&#39;t bind to &#39;ngModel&#39; since it isn&#39;t a known property of &#39;select&#39;

♀尐吖头ヾ 提交于 2019-11-26 02:25:14
问题 EDIT: Updated Plunkr: http://plnkr.co/edit/fQ7P9KPjMxb5NAhccYIq?p=preview this part works: <div *ngFor=\"let entry of entries | async\"> Label: {{ entry.label }}<br> Value: {{ entry.value }} </div> but I\'ve problems with the select box, the error message is: Can\'t bind to \'ngModel\' since it isn\'t a known property of \'select\' The whole Component: //our root app component import {Component} from \'@angular/core\'; import {NgFor} from \'@angular/common\'; import {HTTP_PROVIDERS, Http}