Linked Questions

Popular Questions

Angular: Bind observable and evalute results

Asked by At

I want to have structure like

MyStruc {
   action2Execute:any; // see #q3

   constructor(coll: CollectionServices) {
    // see #q1

and have a ServiceClass like

MyServiceClass {
  constructor(public http: HttpClient) { }


and a Controller class like

MyControllerClass {

  constructor(private coll: CollectionServices) {}
  execHTTP() {
     new MyStruc(coll).action2Execute.apply(1);


Now my purpose is to bind action2Exectue to the method myHTTPRequest, call it and process the results. I have two problems with this

  1. If I set action2Execute like this.action2Execute=coll.myHTTPRequest than I have the problem when I call it in MyControllerClass.#execHTTP() I get an error which says: TypeError: Cannot read property 'get' of undefined ==> http is undefined

  2. My other problem is that by just using apply I do not get the results from the observable, i.e. from the HTTP request.

  3. What type should have action2Exectue in the class MyStruc?

Related Questions