Angular 2 - pipes inside ngIf through cross domain

26 views
Skip to first unread message

pfled...@gmail.com

unread,
Mar 22, 2017, 10:57:45 AM3/22/17
to Angular and AngularJS discussion

Hello everyone,


I got an ngIf div that contains piped translations, outside of the ngIf they work, inside of it, it depends (pipes are pure and should then be refreshed when translations arrive)


I load translation inside a service, pipes are all subscribed to an observable from that service so they get notified when translations arrive and refresh themselves

in another service, I load product informations, if I load that json via http,

  • it works when the json is part of the angular project

  • it does not work if the json is on another url (php)

  • problem is intermitent (adding an empty line in any file makes the plunkr refresh and sometimes translations show up, sometimes not)

I created a plukr https://plnkr.co/edit/RITJVLa19UvqDhzvXzgs


the whole problem is in src/data.service.ts, you can see one "does work" line and one "does not work line"


I cant figure why it's not working, in both cases, the json and traductions get fetched


thanks

Curtis Newton

unread,
Mar 27, 2017, 4:19:03 AM3/27/17
to Angular and AngularJS discussion
thx for the wonderfull support, folks

Sander Elias

unread,
Mar 27, 2017, 7:34:40 AM3/27/17
to Angular and AngularJS discussion
Hi,

Your pipe is impure, so you need to set it like impure, and it will start working. If you don't the working is dependent on the execution order of your program, wich may change, causing your pipe to do exactly whet your issue is.

Regards
Sander

Reply all
Reply to author
Forward
0 new messages