I have found the solution :
$scope.url = '/scripts/json/myfile.json';
$scope.myData = [];
$http.get($scope.url)
.success(function (thisdata) {
//convert data to array
var listePrestataires = angular.fromJson(thisdata);
$scope.listePrestataires = listePrestataires.prestataires;
})
//if error
.error(function (data, status) {
$scope.listePrestataires = data || "Erreur dans la requête
HTTP.";
$scope.status = status;
});
//we build the array
$scope.gridOptions = { data: 'listePrestataires' };
Le vendredi 28 février 2014 14:17:36 UTC+1, Kévin Ribot a écrit :
>
> Thanks for your answer.
>
> I don't see how fill my $scope.gridOptions out of my $http call.
> I need read an JSON file before.
> I try with angular.fromJSson(), but without success.
>
>
>
>
> Le vendredi 28 février 2014 11:47:50 UTC+1, Zhenghao Huang a écrit :
>>
>> Ah! I've encountered this before!
>>
>> Don't wrap your $scope.gridOptions = { data: 'myData' }; inside the
>> $http call. I'm not sure if the next step is required but, ensure you
>> initialize $scope.myData outside of the $http call first.
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.