Vote count:
0
I use $http.get() to read the json data from the file and we assign the readed data to another scope variable.But the problem is first it assign the value to the scope variable then its call the success function.
Controller
var app = angular.module("myapp", []);
app.controller('MyControl', function ($scope, $http) {
var $config = {
url: 'CriticalPath.json',
method: 'GET',
async: true,
transformResponse: function (value) {
return $.parseJSON(value, true, true);
}
}
$scope.myData = [];
$http($config).success(
function (response) {
$scope.myData = response;
}).then(function () {
var anchorTime = $scope.myData[0].StartTime.clone();
for (var i = 0; i < $scope.myData.length; i++) {
$scope.myData[i].UpdateCriticalPathColor = function (data) {
var isCritical = CriticalPathActivities.indexOf(data) != -1;
if (isCritical)
return { "background-image": 'url(Images/redBar.png)', "border- color": 'red' };
else
return { "background-image": 'url(../Scripts/Src/Styles/Images/TaskBar.png)', "border-color": '#050DFA ' };
}
}
});
$scope.Options = {
DataSource: 'myData',
};
});
We want to call the success function first
Help me to solve this problem
asked 2 mins ago
AngularJs:$http.get() is not working properly
Aucun commentaire:
Enregistrer un commentaire