I am new to AngularJS and trying to fix the problem when some of the HTML code is displayed before ng-if status determination. I am hsing ng-cloak as mentioned in many other stack urls downstream, but it still does not work for me. I am trying to load a default image if the actual image at the url is blank and when the page loads even if the actual url is there, it first blinks with the default image and loads the actual image because ng-cloak is not working properly.
Please, help.
I have code and CSS, etc.
Index.html
<!DOCTYPE> <html> <head> <meta charset="UTF-8"> <base href="/"> <title>Some App</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-resource.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-route.min.js"></script> <script src="https://code.angularjs.org/1.4.7/angular-sanitize.min.js"></script> <style type="text/css"> [ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { display: none !important; } </style> </head> <body ng-app="app"> some code here <div ng-view></div> </body> </html>
other.html
<div class="content"> <div style="width: 100px; height: 40px;"> <div ng-if="image.small"> <img src="{image.small}}"> </div> <div ng-if="!image.small" ng-cloak> <img src="image/default.png"> </div> </div>
source share