Instagram API를 사용하여 이미지를 가져 오는 Angular 앱을 만들었습니다. 사용자가 나중에 이미지를 삭제하면 내가 깨진 이미지 (404 's)로 끝납니다. jQuery를 사용하여 이러한 (깨진) 이미지가 포함 된 div를 숨기려고했지만 여전히 나타납니다.Angular app에서 깨진 이미지를 숨기는 방법
내가 내 'index.html을'파일에서 참조는 'custom.js'파일에 다음 jQuery를 배치 한:
$(document).ready(function() {
$("img").error(function() {
$(this).parent().hide();
});
});
내가 머리에 다음 'custom.js'jQuery를 참조
<script src="libs/jquery/dist/jquery.min.js"></script>
<script src="js/custom.js"></script>
... 그리고 여기에 내가이 jQuery를 적용하려고 해요 HTML입니다 :
<a ng-href="{{image.link}}" target="_blank" title="{{image.text}}"><img ng-src="{{image.img}}" alt="" class="img-responsive" ng-style="homeColors" id="image"></a>
왜 제거하지? 다시 표시 할 필요가 없습니다. – cychoi
@cychoi, 제거도 옵션이 될 것입니다. 문제는 위의 jQuery가 현재 전혀 작동하지 않고 있으며 그 이유를 파악할 수 없다는 것입니다. – MattDionis
제공 한 코드가 작동합니다. 여기를 확인하십시오 : http://jsfiddle.net/fqxw0dqg/ – cychoi