1

This is my code, I'm trying to render a list of items should contain "type_transaction" is equal to "paypal" and im trying to avoid rendering different than "paypal".

DATA in JSON:

    {
        "orders":[
            {
                "id_order":"374",
                "type_transaction":"paypal"
            },
            {
                "id_order":"373",
                "type_transaction":"credit-card"
            },
            {
                "id_order":"372",
                "type_transaction":"credit-card"
            },
            {
                "id_order":"371",
                "type_transaction":"paypal"
            }

        ]
   }

HTML:

                    <tbody ng-init="get_orders()">
                        <tr ng-repeat="order in orders | filter:searchText">
                            <td>{{order.id_order}}</td>
                            <td>{{order.type_transaction}}</td>
                        </tr>
                    </tbody>

Javascript function will apply the filter to display a list according if their items are same to "Paypal":

$scope.get_orders = function(n) {

    $http.post(url, $scope.main ).success(function(data){
      $filter('filter')(data.orders, "'type_transaction': 'paypal'", true) = data.orders;
        //$scope.orders = data.orders;
    });
}

It gave me an error, it showed ReferenceError: Invalid left-hand side in assignment I still don't understand how $filter works.

3
  • try with ng-if in your html view Commented May 23, 2016 at 21:50
  • @amani92 Can you elaborate this? I tried to put ng-if="'type_transaction': 'paypal'" with ng-repeat, so it won't work Commented May 23, 2016 at 21:54
  • $filter('filter')(...)=data.orders; Your error is not about $filter - it's how javascript works. Commented May 25, 2016 at 18:19

1 Answer 1

1

Try to surround string (paypal) with quotes ':

ng-if="order.type_transaction=='paypal'"

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.