i'm currently working on a back-end website in Angular with very little underscore.js. For my back-end i'm using the php-framework Laravel 4 which is very Handy. The problem i'm facing is :
When i query an url with angular the response is nice and clean so i can ng-repeat with no problem. But when i'm trying to extract the first element of the response with underscore, it gives me : undefined.
here's an extract of the code of my Controller:
var Client = $resource('myUrl/that/works/fine/and/returns/well');
var resultat = Client.query();
$scope.clients = resultat ;
$scope.isAnArray = _.isArray(resultat); // it returns true;
if i now try the line bellow $scope.myFirstElemInArray is undefined ???
$scope.myFirstElemInArray = _.first(resultat ); // expected:the first element.
I really don't see what's wrong with it. Here's the content of my variable resultat:
[{"id":"2","email":"[email protected]"},{"id":"3","email":"[email protected]"}]
If somebody can give a little help, i'm really getting crazy with this Olivier (Fr)