Hi,

I have a mysql database with a column called "date". When I use the 
following code it returns date is undefined, but yet I have a column called 
"date" in my database, so my query must not be selecting my json data?

 $scope.quote = data.filter(function(quote) {
      return quote.date == y + '-' + m + '-' + d;
    })[0];


This is the full code:

 $http.post('ajax/getQuotes.php').success(function(data){

    var now = new Date();
    var d = now.getDate();
    var m = now.getMonth() + 1;
    var y = now.getFullYear(); 


    // filter down to the quote with today's date but returning date is not 
defined
    $scope.quote = data.filter(function(quote) {
      return quote.date == y + '-' + m + '-' + d;
    })[0];


  });

And this is a sample of my json data (I have shifted the array so the id 0 
is null because of how I used to return days):

[null,{"id":"1","quote":"I know where I'm going and I know the truth, and I 
don't have to be what you want me to be. I'm free to be what I want.",
"author":"Muhammad Ali","background":"images\/manhattan.jpg","date":
"2015-01-01"},{"id":"2","quote":"Setting goals is the first step in turning 
the invisible into the visible.","author":"Tony Robbins","background":
"images\/sunrise.jpg","date":"2015-01-02"}]

Anyone could give me some pointers? I also tried some 3rd party plugins to 
filter json data but according to an acquaintance I don't need to do all 
that.
Thanks! :)

-- 
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/d/optout.

Reply via email to