Angular2 – How do I inject a service into a custom exception handler

Issue I have a custom exception handler like this in which I’m trying to inject a service (ErrorReportingService) import { ExceptionHandler, Injectable } from ‘@angular/core’; import {ErrorReportingService } from ‘../services/ErrorReportingService’; @Injectable() export class InsightsExceptionHandler extends ExceptionHandler { constructor(private _errorReporter: ErrorReportingService)

Continue reading

How to subscribe to event emitter once?

Issue // Part of service public someEvent: EventEmitter<number> = new EventEmitter(); …. // Component @Component({ selector: ‘some-component’, template: `…` }) export class SomeComponent { constructor(public service: Service) { this.service.someEvent.subscribe((x) => { // Do something }); } } SomeComponent is displayed

Continue reading

Angular2 scope's and components

Issue All, This is what I have: user-list.component.ts export class UserListComponent { public userSerivce: UserService; public deleteUser(id) { this.userSerivce.delete(id); } } user-list.component.html <div> <some-reusable[deleteFunc]=”delete” > </some-reusable><!– this will bind “delete” on the user- list.component, to “deleteFunc” on SomeReusableComponent–> </div> some-reusable.component.ts

Continue reading

Angular 2 Inject complex service to service

Issue I have three services and one component: root.service abstarct-child.service extend-child.service app.component The root.service injects by using dependency injection the abstarct-child.service, like so: import {Injectable} from ‘angular2/core’; import {AbstractChildService} from ‘./abstarct-child.service’; @Injectable() export class RootService { constructor(private _abstractChildService: AbstractChildService) {}

Continue reading

Angular2 Http get

Issue I am trying to be pull data from API using Angular2, and bind it to view. After request been done, my component only gets array object [object Object],[object Object],[object Object]. Can I get any help on extracting the object

Continue reading

child component EventEmitter not working

Issue I have CreateProjectComponent which is child component I need to close a div in Parent when closeModal is clicked The template (html): <div (click)=”closeModal(true)”></div> The component.ts @Component({ moduleId: module.id, selector: “th-create-project”, templateUrl: “create-project.component.html”, styleUrls: [“create-project.scss”], directives: [ ThAutocomplete, MD_CARD_DIRECTIVES,

Continue reading

BehaviorSubject in Angular2 is not set value second time?

Issue My code is like login.component.ts loginSucess () { this.MenuService.setUserName(userauthresponce.username); } MenuService.ts private usernameSource = new BehaviorSubject<any>(0); setUserName (username) { this.usernameSource.next(username); } getUserName () { return this.usernameSource.asObservable(); } other.component.ts constructor(MenuService:MenuService) { this.MenuService.getUserName().subscribe(responce => { console.log(‘username’, responce); this.username = responce; });

Continue reading

Angular 2 Http Error

Issue I’m new in Angular 2 and I am very stuck on HTTP. The application runs but when I try get my InMemoryDbService it fails. The error is: EXCEPTION: Uncaught (in promise): TypeError: Cannot read property ‘0’ of undefined but

Continue reading

calling success, error callbacks using subscribe in angular2?

Issue Giving responce.json () is not function for my case component.ts this.AuthService.loginAuth(this.data).subscribe(function(response) { console.log(“Success Response” + response) }, function(error) { console.log(“Error happened” + error) }, function() { console.log(“the subscription is completed”) }); AuthService.ts loginAuth(data): Observable<any> { return this.request(‘POST’, ‘http://192.168.2.122/bapi/public/api/auth/login’, data,{

Continue reading

Angular2 location.back() page reloads?

Issue I am in need to give a Go-Back button for this I am using location services as: import {Location} from ‘@angular/common’; backclicked(): void { console.log(“back clicked.”); this.location.back(); } <a id=”redirect-link” (click)=”backclicked();” style=”padding:8px 15px;” > Issue is this that location.back()

Continue reading

Binding data to template after making a call to service using http.get in angular2

Issue Service let options = new RequestOptions({ headers: this.headers }); let body = JSON.stringify(this.params); return this.http.post(this.url,body, options) .map((res: Response) => res.json() as Observable<Proc>) .catch((error: any) => Observable.throw(error.json().error)) Component this.procservices.GetProcData(this.selectedServer,”test”,”test2″) .subscribe(res => { this.inventoryList = res as Proc[]; console.log(this.inventoryList); }, error

Continue reading

Angular 2 :Uncaught (in promise): RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded

Issue I just begin working with angular 2. so I try to display categories from data base using web service. this is my forum.service.ts file public getCategories(){ return this.http.get(‘http://localhost/ForumLaraAngular/public/api/forum’).map((res: Response) => res.json()); } forum.component.ts: categories:any; constructor(private forumService:ForumService) { } ngOnInit():

Continue reading

Binding a dynamic object to Html using Angular2

Issue this.procFilterResults: any[]; this.procservices.GetProcData(this.selectedServer, this.selectedProjectName, this.selectedProc, this.procInput,_inputs ) .subscribe(res => { this.procFilterResults = JSON.parse(res); this.Keys=Object.keys(this.procFilterResults[0]); console.log(this.procFilterResults); }, error => this.errorMessage = <any>error); <table class=”table table-bordered”> <thead> <th *ngFor=”let key of Keys”> {{key}} </th> </thead> <tbody> <tr *ngFor= ‘let res of

Continue reading

Angular 2 load data before render template

Issue I have the following html code: <tbody ng-repeat=”caterory in data”> <tr> <td [colSpan]=”segment”>{{ caterory.name }}</td> </tr> <tr ng-repeat=”room in caterory.rooms”> <td>{{room.room_no}}</td> <td [colSpan]=”schedule.dayDiff” ng-repeat=”schedule in room.reservations”>{{schedule.firstName}}</td> </tr> </tbody> When I run I’m getting the following error: TypeError: Cannot read

Continue reading