title: Angular 4 Observable and ionic 3 - works the first 2 times, and then saying is not a function
body: <p>I'm having a weird problem.</p>
  
  <p>I have a page called feed with files: feed.ts and feed.module.ts</p>
  
  <p>On feed.ts I have this function:</p>
  
  <pre><code>  likeImage(image){
  
      console.log("Right before subscribe");
      this.imageMng.likeImage(image).subscribe((data) =&gt; {
        image.likes_image = data.status;
        image.numberOfLikes = data.numberOfLikes;
      });
    }
  </code></pre>
  
  <p>Which is subscribing to image-management.ts</p>
  
  <pre><code>   likeImage(image): Observable&lt;any&gt; {
      let data = new URLSearchParams();
      data.append('image_id', image.id);
      data.append('access_token', this.userMng.getToken());
  
      return Observable.create(observer =&gt; {
        this.http.post(this.likeLocal, data).map(res =&gt; res.json())
          .subscribe(
            data =&gt; {
              if (data.status == "restored" || data.status == "liked") {
                this.likeImage = data.status;
                observer.next({status: true, numberOfLikes: data.likes});
                //observer.complete();
              }
              if (data.status == "deleted") {
                observer.next({status: false, numberOfLikes: data.likes});
                //observer.complete();
              }
              observer.complete();
            },
            err =&gt; {
              console.log(err);
              observer.next(err);
              //observer.complete();
  
            }
          );
  
      });
  
    }
  </code></pre>
  
  <p>The view that is being loaded is: images.html</p>
  
  <pre><code>  &lt;ion-row&gt;
      &lt;ion-col&gt;
        &lt;button ion-button [color]="image.likes_image ? 'danger' : 'primary'" clear small icon-start (click)="likeImage(image);"&gt;
          &lt;ion-icon name='thumbs-up'&gt;&lt;/ion-icon&gt;
          &lt;span *ngIf="image.numberOfLikes;then image_likes_from_likes_update else image_likes_from_server"&gt;&lt;/span&gt; Synes godt om
          &lt;ng-template #image_likes_from_likes_update&gt;{{image.numberOfLikes}}&lt;/ng-template&gt;
          &lt;ng-template #image_likes_from_server&gt;{{image.likes.length}}&lt;/ng-template&gt;
        &lt;/button&gt;
      &lt;/ion-col&gt;
      &lt;ion-col&gt;
        &lt;button ion-button color="primary" clear small icon-start&gt;
          &lt;ion-icon name='chatbubbles'&gt;&lt;/ion-icon&gt;
          {{image.comments.length}} Kommentarer
        &lt;/button&gt;
      &lt;/ion-col&gt;
      &lt;ion-col center text-center&gt;
        &lt;ion-note&gt;
          {{image.created_at | amTimeAgo}}
        &lt;/ion-note&gt;
      &lt;/ion-col&gt;
    &lt;/ion-row&gt;
  </code></pre>
  
  <p>When I click on "likeImage(image)" - it works, and makes a POST request to the server, and updates everything as expected.</p>
  
  <p>If I do it again, it still works - BUT if I do it the third time, it gives me this error:</p>
  
  <p><a href="https://i.stack.imgur.com/nC7da.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nC7da.png" alt="this.imageMng.likeImage is not a function"></a></p>
  
  <p>What am I doing wrong?</p>