Reputation: 563
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
Upvotes: 0
Views: 459
Reputation: 2018
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.
Upvotes: 3
Reputation: 58593
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.
Upvotes: 0