javascript - Getting error with ng-if in angularjs -


i using ng-if tag in app, seems when load page, throws error.

here how code looks

<ons-col width="95px">               <img src="{{postdetail.attachments[0].images.square1.url}}" class="thumbnail" ng-if="postdetail.attachments[0].url != null">               <img src="images/location1.png" class="thumbnail" ng-if="postdetail.attachments[0].url == null"> </ons-col> 

when page loads or when reload shows below error:

get file://localhost/volumes/work%20data/development/come%20to%20woodstock%20ic…o%20woodstock/www/%7b%7bpostdetail.attachments[0].images.square1.url%7d%7d net::err_file_not_found

is there problem in ng-if? looks while works on browser, when load console in google chrome, can see of these above mentioned weird errors. solutions?

to avoid browser eagerly retrieving image not-yet-interpolated url, e.g. src="{{some.url}}" (thus resulting in http error), should use ng-src:

<img ng-src="{{postdetail.attachments[0].images.square1.url}}"> 

as ng-if, seems guard against null postdetail.attachments[0].url - sure didn't mean postdetail.attachments[0].images.square1.url?


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -