私はここに少しジレンマがあります。私は(jQueryのUIソート可能に基づく)NGリピート内にあるとAngularJS UI Sortableを使用してソート可能であるネストされたJSONオブジェクトを持っている:Angularjs JSonオブジェクトを削除します
$scope.rootItem = {
id: '1',
type: 'course',
title: 'Adobe Photoshop CC for beginners',
items: [{
id: '2',
type: 'label',
title:'label',
items:[{
id: '3',
type: 'module',
title:'Module title',
items: [{
id: '4',
type: 'topic',
title:'Topic title',
items: [{
id: '5',
type: 'content',
title:'Content title'
}, {
id: '6',
type: 'content',
title:'Content title'
}]
}]
},{
id: '7',
type: 'resources',
title:'Resources'
},{
id: '8',
type: 'module',
title:'Module title',
items: [{
id: '9',
type: 'topic',
title:'Topic',
items: [{
id: '10',
type: 'question',
title:'Question title'
}]
}, {
id: '11',
type: 'topic',
title:'Topic title',
items: [{
id: '12',
type: 'content',
title:'Content title'
}]
}]
}]
},{
id: '14',
type: 'assessmentLabel',
title: 'Assessment Label',
items: [{
id: '15',
type: 'assessment',
title: 'Assessment Title',
items: [{
id: '16',
type: 'courseAssessment',
title: 'Course Question Group',
items: []
}]
}]
}]
};
私が行うことができるはず何がこのオブジェクト内の項目のいずれかを削除し、そしてあります子どもがいる場合は、それも削除する必要があります。
だから私は一般的に$ indexとspliceを使ってそれを削除しています(配列の場合)。
しかし、このように動作するように見えるdoesntのオブジェクトのために、私は私のボタンで...
を代わりに使用してください削除オンラインを読んで、私はのようにオブジェクト自体を渡ししよう:
data-ng-click="removeItem(ngModelItem)"
私のコントローラでは次のようなことをします:
// Remove Item from the list
$scope.removeItem = function(item) {
};
何か提案がありますか?
あなたはそれはあなたがいない親オブジェクトまたは子配列項目であったかどうかを考慮して知っているだろうか?ビューがどのように構成されているかを確認する必要があります – charlietfl