question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Working with Observables of custom services

See original GitHub issue

The next code is not working for me 😕 Am I forgetting something?

Error in ./Ng2AutoCompleteComponent class Ng2AutoCompleteComponent - inline template:4:4 caused by: Cannot read property 'GetbyCategoryName' of undefined

Method public searchRegularCategories(term: string) { return this._categoriesService.GetbyCategoryName(term).map(x => x.data); } Html <input ng2-auto-complete [list-formatter]="myListFormatter" [source]="searchRegularCategories" type="text" display-property-name="description" accept-user-input="false" placeholder="Write the category name" #category>

Service public GetbyCategoryName(name: string ): Observable<RG<ListingCategory[]>> { return this._http.get(http://localhost:53903/api/v1/categories/regular?name=${name}`, { headers: this.headers }) .map((resp: Response) => resp.json()) .catch((error: any) => { return Observable.throw(error); }); }`

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
allenhwkimcommented, Jan 23, 2017

it’s about this context. I am not sure why it must be assigned as a variable.

@ndcunningham can you investigate that if it is possible to assign a method instead of a variable for this.

Related source code: https://github.com/ng2-ui/ng2-auto-complete/blob/master/src/ng2-auto-complete.component.ts#L212

0reactions
Jonatthucommented, Jan 27, 2017

Thank you very much, It is working !

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to build Angular App with Observable Data Services
In this post we are going to see how an Angular application can be built around the concept of observable data services.
Read more >
Using observables to pass values - Angular
An Observable instance begins publishing values only when someone subscribes to it. You subscribe by calling the subscribe() method of the instance, passing...
Read more >
Custom Observable using Rxjs - Aspire Blogs
In this blog, I will explain about ”Custom Observable”. Here the motive behind the writing of this blog is to understand the working...
Read more >
Understanding, creating and subscribing to observables in ...
Observables are a new way of pushing data in JavaScript. An observable is a Producer of multiple values, “pushing” them to subscribers. Observables...
Read more >
Angular Observable Data Services - Cory Rylan
A tutorial on how to use Observables and how they can improve your Angular data services and managing state in your applications.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found