angular2-services

Not able to consume external webapi service from angular2 service

与世无争的帅哥 提交于 2019-12-12 03:44:16
问题 My requirement is to create a angular2 component which would consume the external WebAPI service and generate a bubblechart based on the data received. I have created a Dataservice component which would make the http get request. the code for Dataservice is below import { Injectable } from 'angular2/core'; import { HTTP_PROVIDERS, Http, Headers, Response, JSONP_PROVIDERS, Jsonp } from 'angular2/http'; import { Configuration } from './Configuration'; import 'rxjs/add/operator/map' import {

Jasmine gives Cannot read property 'getXHR' of null for Angular 2 unit test

扶醉桌前 提交于 2019-12-12 03:15:25
问题 I have found many examples online of unit testing Angular 2 with a http call. However when I make my own test and run it Jasmine it gives me an error: http Http .request() should accept a fully-qualified request as its only parameter Failed: Cannot read property 'getXHR' of null import { afterEach, beforeEach, ddescribe, describe, expect, iit, inject, injectAsync, it, xit } from "angular2/testing"; import {Injector, provide} from "angular2/core"; import {MockBackend, MockConnection} from

Angular 2 http module load issue

﹥>﹥吖頭↗ 提交于 2019-12-12 03:09:46
问题 I'm trying to start to rewrite an Angular1 app into Angular 2 app. I start this new project with th help of angular-cli but I'm block to import http service. I added the following line in my main.ts import { HTTP_PROVIDERS } from '@angular/http'; And this one in my service that need to use http import { Http, Response } from '@angular/http'; And for there two lines I have the following error: Cannot find module '@angular/http' Have you some Idea about what can i miss ? Thank you. 回答1: you

Angular2 Data Service Component not receiving value on Other components

核能气质少年 提交于 2019-12-12 02:32:26
问题 currently I am using Shared services to pass data from one component into other i set the value on first component and trying to retrieve value on other end, but I am receiving empty array here is my code: **Ist Compnent:** @Component({ templateUrl: './landingPage.component.html', styleUrls: ['./landingPage.component.css'], providers: [LandingService], }) export class LandingPageComponent { constructor(private landingService:LandingService) { } @Input() Location:string; @Input() Type:string;

angular2 service request header response for X-Pagination-Page-Count

喜欢而已 提交于 2019-12-11 17:56:46
问题 I am using angular2 service to get data response from yii2 api. In browser network tab it showing all required response but when I am trying to get it directly from component like response.headers.get('X-Pagination-Page-Count') Then it's not showing anything. except only showing content-type in response header via code. but can't get a function response. below is my service function. getResponse(endpointUrl: string): Observable<any> { const url = url; return this._http.get(url) .catch((err) =

how to get value outside subscribe in angular2

久未见 提交于 2019-12-11 16:22:48
问题 Well, I have created a function inside the component.ts file which is placed inside the constructor: constructor(private _visitService: VisitService,) { this._visitService.getchartData().subscribe(data => { this.fetchedData = data console.log("INSIDE SUBSCRIBE", this.fetchedData ); }); } It is fine when the data is to be used within the subscribe curly brackets {} like the console.log did. but when i put it in a function outside like this: constructor( private _visitService: VisitService, ) {

Angular Service Broadcast not working with routing

僤鯓⒐⒋嵵緔 提交于 2019-12-11 16:18:48
问题 When subscribed to an event in Service, I can access the data it emits in another component, But when I am trying to route the page the data is being set in ngOnInIt() after the routing process starts it is being set to default. The service is registered in app.module.ts so it is same across the app. This component will emit an event with the index of the recipe user clicked. import { Component, OnInit, Input } from '@angular/core'; import { Recipe } from '../../files/recipe.model'; import {

Angular 5 APP_INITIALIZER gives Cyclic dependency error

我的梦境 提交于 2019-12-11 15:25:29
问题 Angular 5 error. I am having trouble with getting user details on page refresh from browser. I am trying to load the data using APP_INITIALIZER but getting below error - compiler.js:19390 Uncaught Error: Provider parse errors: Cannot instantiate cyclic dependency! ApplicationRef ("[ERROR ->]"): in NgModule AppModule in ./AppModule@-1:-1 Below is my configuration app.module.ts export function initUserFactory(userService: UserService) { return () => { userService.initUser()}; } let INITIAL

Angular2 HTTP Providers, get a string from JSON for Amcharts

本秂侑毒 提交于 2019-12-11 14:37:31
问题 This is a slightly messy questions. Although it appears I'm asking question about amCharts, I really just trying to figure how to extract an array from HTTP request and then turn it into a variable and place it in to 3-party javacript. It all starts here, with this question, which was kindly answered by AmCharts support. As one can see from the plnker. The chart is working. Data for the chart is hard coded: `var chartData = [{date: new Date(2015,2,31,0,0,0, 0),value:372.10,volume:2506100},

InMemoryWebApiModule - status: 404 - collection not found

£可爱£侵袭症+ 提交于 2019-12-11 13:42:45
问题 I'm trying to use angular2 InMemoryWebApiModule and implement the InMemoryDbService, to create a mock-up of my backend server. I configured it as (I thought) it should be, but somehow I can't reach the data structure that implement the InMemoryDbService (WorkerData in worker.ts) and keep getting status 404 ("Collection 'workers' not found"). I've simplified the code to make it clearer. This is a URL issue - can't figuring out why. The problem occurs when executing the getWorkrs function in