아이템을 나열하는 인벤토리를 만들었으며 아이템을 클릭하면 유사한 아이템을 볼 수 있습니다. 사용자가 그 목록이 닫힌 후 내가 유사한 항목 요소를 제거하면 ... 문제가 발생엘리먼트를 제거하면 ng-repeat 코멘트가 남음
<!-- ngRepeat: item in category.items(3606) | orderBy:'sort_order' -->
<!-- end ngRepeat: item in category.items(3606) | orderBy:'sort_order' -->
를 뒤에 잎 범위에서, 각도가 NG-반복 재현 경우 해당 항목이 다른 업데이트 될 때마다 때문에 표시합니다. 나는 그 요소를 잘못 파괴하고 있는가?
app.directive('similar', function($rootScope, $compile, $templateCache, Item, Allo){
return {
restrict: 'A',
link: function(scope, elem, attrs) {
var unqId = _.uniqueId('similar');
elem.on('click', function(){
// if user closes the list of similar items, destroy the contents
if (elem.hasClass('glyphicon-upload')) {
elem.removeClass('glyphicon-upload');
angular.element('.'+ unqId).remove();
return;
}
elem.addClass('glyphicon-upload');
var itemId = scope.$parent.item.id;
var similars = scope.similars[itemId];
if (similars) {
var row = $templateCache.get('inventory/views/_row.htm');
var html = $compile('<tr class="'+ unqId +'" ng-repeat="item in category.items('+ similars +') | orderBy:\'sort_order\'">'+ row +'</tr>')(scope);
elem.parents('tr').after(html);
}
});
}
};
});