Seems like a very basic question but I can't get the syntax right..
<li class="list-group-item" ng-repeat="question in newSection.Questions | filter:Id != '-1'; " ng-mouseenter="hover = true" ng-mouseleave="hover = false"> <div href="#" editable-text="question.Text">{{question.Text}}</div> </li>
All I want is to show all the questions where id is NOT -1. What am I doing wrong. Thanks!
Option C is not a valid AngularJs Filter. Filters are used to change modify the data and can be clubbed in expression or directives using pipe character. Filters can be added to expressions by using the pipe character |, followed by a filter. AngularJS provides filters to transform data.
The “filter” Filter in AngularJS is used to filter the array and object elements and return the filtered items. In other words, this filter selects a subset (a smaller array containing elements that meet the filter criteria) of an array from the original array.
The syntax is just a little off, try:
<li class="list-group-item" ng-repeat="question in newSection.Questions | filter:{ Id: '!-1'}" ng-mouseenter="hover = true" ng-mouseleave="hover = false"> <div href="#" editable-text="question.Text">{{question.Text}}</div> </li>
See a little JSFiddle: http://jsfiddle.net/U3pVM/3845/
Edit:
Example with variables:
<script> var invalidId = '-1'; </script> <li class="list-group-item" ng-repeat="question in newSection.Questions | filter:{ Id: '!' + invalidId}" ng-mouseenter="hover = true" ng-mouseleave="hover = false"> <div href="#" editable-text="question.Text">{{question.Text}}</div> </li>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With