काम कर रहे plunker देखें।
तुम सिर्फ एक ऐड की जरूरत है और अपने नियंत्रक
$scope.addGroup = function(idx, group, e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
var newGroup = angular.copy(group);
newGroup.no = $scope.groups.length + 1;
$scope.groups.splice(idx + 1, 0, newGroup);
};
$scope.removeGroup = function(idx, e) {
if (e) {
e.preventDefault();
e.stopPropagation();
}
$scope.groups.splice(idx, 1);
};
और अपने html के लिए एक ng-repeat
में समारोह को दूर:
<accordion close-others="oneAtATime">
<accordion-group heading="{{group.title}}" ng-repeat="group in groups">
<accordion-heading>
{{ group.title }} ({{group.no}})
<button class="btn btn-small" ng-click="addGroup($index, group, $event)">+</button>
<button class="btn btn-small" ng-click="removeGroup($index, $event)" ng-show="$index">-</button>
</accordion-heading>
{{group.content}}
</accordion-group>
</accordion>
हाय बेकोस, यही वह है जिसे मैं ढूंढ रहा हूं। आपने मेरी समस्या हल की। धन्यवाद आप – user2801604
कमाल धन्यवाद! मुझे $ इवेंट var के बारे में पता नहीं था इसलिए यह एक बड़ी मदद थी! –