0

After 5hrs of struggle I decide it to ask question to see if someone can help me. I use Angular 2 for front end of application and now I have a problem to upload image on my server. Problem is after uploading because my page is reloading again. I use angular2-image-upload. In app.module i add this:

@NgModule({
    imports: [
        ...,
        ImageUploadModule.forRoot(),
        ...
    ]
})

In html file I have this:

 <image-upload
    [max]="100"
    [url]="'http://myurl'"
    [buttonCaption]="'Select Images!'"
    [dropBoxMessage]="'Drop your images here!'"
></image-upload>

And everything is ok, image was upload, but in console I got this information

[WDS] App updated. Recompiling..

and page is reloading.

Can anyone knows why this happening?

Thanks in advance

Sasa
  • 553
  • 7
  • 25
  • Hey can you share browser console log? – Aashish Jun 13 '17 at 17:32
  • http://imgur.com/a/VeWrk here is link – Sasa Jun 13 '17 at 17:35
  • Can't say much with that log. Probably you might be missing some imports or some issues with the observables. Just go through the code once again deeply. Hope you find. Also this might can help you as well: https://stackoverflow.com/questions/35985347/how-to-upload-file-in-angular2 – Aashish Jun 13 '17 at 17:45
  • Yes, console log doesn't give any detail. In documentation is just one import, and I don't have an Observable.. :/ – Sasa Jun 13 '17 at 17:51

2 Answers2

3

Probably the reason is, Angular listens all the changes event and refresh. Your image are being uploaded inside the directory where Angular listen changes. For example, if you upload your image and move image inside Angular > src > assets (dir). It will detect changes and reloads whole application.

Consider uploading images outside the src directory. You can also read about how Angular detects changes.

Angular Change Detection - How Does It Really Work?

I know the question is asked a year ago but still if someone gets the same issue this might help.

Ashish Yadav
  • 1,901
  • 2
  • 17
  • 23
0

Issue is while image uploading , because it should not reload the page after image uploading and you are getting this message

[WDS] App updated. Recompiling..

because it reloads the whole app from beginning.

So first step is to check preserve log in console , so it will not refresh the console on page reload , it will show you the error.

Vivek Doshi
  • 56,649
  • 12
  • 110
  • 122