Skip to content Skip to sidebar Skip to footer

Angular Filtering Data In Javascript Is Not Displaying Results And Push Of Data Causes Error Plunker Provided

Ok, seems that I was having too many issues with the way in which my Angular site is setup, so I put it in a plunker as then anyone can see it. Original question: Angular retriev

Solution 1:

Let me try to understand your issue.

As per your question, it seems that you have problems understanding what app is and how to use filter.

This is the working version of your plunkr. Check this url

  1. app in your project is the ng-app directive. The ng-app directive tells AngularJS that the element is the "owner" of an AngularJS application.
  2. For understanding filter functionality. check the below example.
  3. You were trying to push into $scope.statuses which is not defined yet. So first define $scope.statuses to be an empty array i.e `$scope.statuses = [];

Hope this works for you!`

// To declare a filter we pass in two parameters to app.filter// The first parameter is the name of the filter // second is a function that will return another function that does the actual work of the filter//here app is the module name of your project

app.filter('myFilter', function() {

  // In the return function, we must pass in a single parameter which will be the data we will work on.// We have the ability to support multiple other parameters that can be passed into the filter optionallyreturnfunction(input, optional1, optional2) {

    var output;

    // Do filter work herereturn output;

  }

});

Post a Comment for "Angular Filtering Data In Javascript Is Not Displaying Results And Push Of Data Causes Error Plunker Provided"