Reputation: 31
I have upgraded the BlogEngine.Net project to AngularJS 1.7 from 1.3 and JQuery 3.4.1 from 2.1.4. I am having problems getting data from the BlogEngine.Core service. I can get the data from the asp.net app from postman but it wont work through the main 'admin' part of the app.
It seems like the $scope.load function is not defining the widgetzones in the code below
angular.module('blogAdmin').controller('CustomWidgetsController', ["$rootScope", "$scope", "$location", "$filter", "DragDropHandler", "dataService", function ($rootScope, $scope, $location, $filter, DragDropHandler, dataService) {
$scope.widgetZones = {};
$scope.vm = {};
$scope.editSrc = {};
$scope.editId = {};
$scope.editTitle = {};
$scope.editZone = {};
$scope.package = {};
$scope.selectedRating = 0;
$scope.author = UserVars.Name;
$scope.IsPrimary = $rootScope.SiteVars.IsPrimary == "True";
$scope.load = function () {
spinOn();
$scope.widgetZones = {
titles: [],
list1: [], list2: [], list3: []
};
$scope.vm = {};
$("#txtWidgetTitle").parent().removeClass("has-error");
dataService.getItems('/api/widgets', {})
.then(function (data) {
angular.copy(data, $scope.vm);
var zones = $scope.vm.WidgetZones;
for (i = 0; i < zones.length; i++) {
$scope.widgetZones.titles.push(zones[i].Id);
}
if (zones.length > 0) { $scope.widgetZones.list1 = zones[0].Widgets; }
if (zones.length > 1) { $scope.widgetZones.list2 = zones[1].Widgets; }
if (zones.length > 2) { $scope.widgetZones.list3 = zones[2].Widgets; }
spinOff();
})
.catch(function () {
toastr.error($rootScope.lbl.errorLoadingPackages);
spinOff();
});
};
When it tries to get the length of the zones array it shows an error. Can someone please solve for version 1.7 of AngularJS.. I know it's a migration problem but i have tried out several of the migration things on the AngularJS website with no fix...
Upvotes: 0
Views: 77
Reputation: 31
Ahhhh. After about 3 hours I figured out that angular.copy is not working like it used to in angularjs ver. 1.3
I use the json.deserialize function instead of angular.copy
Also I had to add the .data. Part to all of the labels in the html
Upvotes: 0