angular2-services

Accessing async variable of service

蹲街弑〆低调 提交于 2019-12-22 09:18:03
问题 This is part of my first Angular 4 project. I am currently able to call the searchCall function just fine from a search bar, but the data being stored in tweetsData doesn't seem to be in scope with my *ngFor call in app.component.html, as well as being an asynchronous backend call to the twitter api. I get this error: TypeError: Cannot read property 'subscribe' of undefined, so I must not have the observable setup correctly. Any help is greatly appreciated. twitter.service.ts import {

How exactly works the services hierarchy in this Angular 2 application?

此生再无相见时 提交于 2019-12-21 23:16:46
问题 I am very new in Angular 2 and I have the following question about services . Into the main view (the one related to the app.component.ts class) I have this situation: <div class="container"> <div class="row"> <div class="col-xs-12 col-md-8 col-md-offset-2"> <app-new-account (accountAdded)="onAccountAdded($event)"></app-new-account> <hr> <app-account *ngFor="let acc of accounts; let i = index" [account]="acc" [id]="i" (statusChanged)="onStatusChanged($event)"></app-account> </div> </div> <

Angular2: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined

谁都会走 提交于 2019-12-21 10:55:12
问题 I'm new to observables and experimenting with an basic autocomplete variation of Christoph Burgdorf's Observables in Angular2 blog. Running this code produces: EXCEPTION: TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined after issuing the REST get call in ingredientservice...rawsearch. The alert also pops with an [object Object] message. I've verified the endpoint is running fine. Any recommendations on how to debug this would be greatly appreciated. ingredientservice.ts

Angular 2 service constructor with parameter

你。 提交于 2019-12-21 05:41:20
问题 I want to initialize a service with argument. Each component will have its own service instance. @Injectable() export class LoggingService { constructor( @Inject('group') @Optional() public group?: string) { this.group = group; } } It can be injected in to the component like this : @Component({ selector: 'test', templateUrl: 'test.component.html', providers: [ LoggingService, { provide: 'group', useValue: 'Anythings goes here' } ] }) export class TestComponent implements OnInit { constructor

ObjectUnsubscribedError: object unsubscribed error when I am using ngx-progress in angular 2

依然范特西╮ 提交于 2019-12-21 04:02:57
问题 I am using ngx-progressbar bar in Angular 2 application. When app loading first it is working fine. second time it is showing error. I referred few article like medium.com for subscribe object. I did't get clearly. I need to make progress bar every time when click the router links. I attached error snapshot: progress bar code: import { Component, AfterContentInit} from '@angular/core'; import { NgProgress } from 'ngx-progressbar' @Component({ selector: 'link-outlet', template: '<ng-progress

Angular 2 - Including a provider in a service

自闭症网瘾萝莉.ら 提交于 2019-12-20 07:37:45
问题 I have a service loaded into a component as a provider. This service may return data using Http or it may not, the component should not care. However, it seems that the component itself must include HTTP_PROVIDERS if the loaded service uses Http. This breaks separation of concerns. What am I misunderstanding? 回答1: This breaks separation of concerns. What am I misunderstanding? In order to support instantiating multiple instances of a service (i.e., so all services don't have to be singletons)

Pass web application context to Angular2 Service

偶尔善良 提交于 2019-12-20 06:26:24
问题 I'd like to have a variable called _contextPath , which is a Javascript evaluated variable in a JSP, and which is currently available in systemjs.config.js -- I'm trying to have this _contextPath variable available in a Typescript Service. I'd like to know if the _contextPath variable can be passed onto the Typescript Service called job.service.ts Here is my folder structure: ├── scripts │ └── mec-irs │ ├── app | | ├── app.component.ts | | ├── app.module.ts | | ├── app.routes.ts | | └── jobs

Delay navigating to next page

痴心易碎 提交于 2019-12-20 02:13:57
问题 My angular site works great, but when you click into a project it loads the page, right away and sometimes there is a flash while the images are pulled from the API , id like a 1 second delay, or page transition effect. but i'm not sure how to implement this in Angular 2. Interested to hear what others are doing ? Thanks in advance 回答1: You can implement CanDeactivate interface, something like this: routerCanDeactivate(currTree?: RouteTree, futureTree?: RouteTree): Promise <boolean> { return

Iterate through an array of objects Angular 2

泄露秘密 提交于 2019-12-19 19:52:21
问题 I have an array of objects received in service file from a json file. When I subscribe it in the component and try to iterate through it, I am getting the following error: EXCEPTION: Error in app/dashboard/features/fleet/fleetControlPanel/fleetControlPanelTemplate.html:38:14BrowserDomAdapter.logError @ browser_adapter.ts:78BrowserDomAdapter.logGroup @ browser_adapter.ts:89ExceptionHandler.call @ exception_handler.ts:53(anonymous function) @ application_ref.ts:304schedulerFn @ async.ts

ng2-smart-table with paging from back-end (Spring)

拥有回忆 提交于 2019-12-19 17:36:16
问题 I am using a back-end server (Java Spring) that has Pager enabled. I am loading 100 records per page on a HTTP call. On angular2 service, it is consuming the API call with "?page=1&size=100" as the initial call whereas on the client size pager, it shows 10 and moves up to 10 page which is fine. But I am unable to load the next chunk of data from server. I have checked ServerDataSource and used .setPaging(1,100). How can I load the next chunk of data (2-200) and how can I achieve this. Any