Attempting to refresh data after making some changes results in duplicate errors appearing within the ng-repeat.
The scenario is as follows;
I am working on creating a dynamic menu module
The requirements include adding, deleting, changing the order, and assigning items to different Mainmenu items etc.
Everything is functioning properly except for reloading the menu structure in a table format.
After clearing the original Object, the table becomes empty showing no data. When attempting to reload the altered data, duplicate errors occur. The only solution seems to be reloading the browser to display the correct information until the next update.
The challenge lies in not being able to push and splice the array due to potential issues with indentation and the possibility of changing the order.
The code
The module
"use strict";
// no dependencies
angular.module('appWebmenu', []);
The Main Directive
'use strict';
angular.module('appWebmenu').directive('appWebmenu',function() {
return {
scope:false,
controller: 'appWebmenuController',
templateUrl: 'external/appWebmenu/appWebmenuTemplate.html'
};
});
The List Directive The actual table The scope is Moved to the Module Controller
angular.module('appWebmenu').directive('appWebmenuList', function() {
return {
transclude: true,
templateUrl: 'external/appWebmenu/appWebmenuListTemplate.html',
controller: 'appWebmenuController',
scope: false
}
});
The Template
<div ng-if="!listLoaded">
<i class="fa fa-spinner fa-spin fa-3x"></i>
</div>
<div ng-if="listError">
{{ 'ERROR_LOADING' | translate }}
</div>
... (template continues)
And Finally the Controller
angular.module('appWebmenu').controller('appWebmenuController', ['$scope', 'dataService', 'webmenuService', 'loadService', function ($scope, dataService, webmenuService, loadService) {
$scope.title = "Site menu pages"
// Different settings to control view and loading
...
... (controller continues)
The JSON being loaded
{
0: {
...
},
1: {
...
},
...
}
Tried implementing solutions such as using track by $index or a unique identifier like menu_id, but it does not solve the issue and may even worsen it.
If anyone has any insights or solutions, I would greatly appreciate the help.