0

The sales_Use_Taxable field in the database can be one of three options, which are: "Yes", "No", or it can also be null. Using the below code to filter the results, it does not display the rows that have null for this field.

<tr ng-repeat="h in vm.filteredRequisitions = (vm.headers | filter: { por_Detail: { sales_Use_Taxable: vm.tax || '' } }) ...>

I believe the important part of this code is sales_Use_Taxable: vm.tax || ''. How can I edit this line to include the rows that have null for the sales_Use_Taxable field?

1
  • please headers array as well Commented Jan 14, 2019 at 17:09

1 Answer 1

1

To achieve expected result , change empty quotes '' to undefined which will return all rows including null values

var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
  //$scope.tax = 'YES'
  $scope.headers = [
    {"por_Detail" : {
       "sales_Use_Taxable" : null
    } },
    {"por_Detail" : {
       "sales_Use_Taxable" : 'YES'
    } },
    {"por_Detail" : {
       "sales_Use_Taxable" : 'NO'
    } }
  ]
});
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>

<body ng-app="myApp" ng-controller="myCtrl as vm">
<table>
<tr ng-repeat="h in headers | filter: { por_Detail: { sales_Use_Taxable: tax || undefined} }">
  <td>{{h}}</td>
  </tr>
  </table>



</body>
</html>

codepen for reference with example - https://codepen.io/nagasai/pen/WLPrPj

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.