31

I want to filter on a select like so :

<select ng-model="test" ng-options="c as c.label group by c.type for c in columns
| filter:{c.type:'!field'} | filter:{c.type:'!map'}"></select>

EDIT : Adding the column model :

Columns = [
{
    name: "name",
    label: "Label",
    info: "Information displayed in help",
    type: "type",
    view: "html template",
    style: "min-width: 10em;",
    show: true
},
{
 ...
}
];

Columns is used for several things and to optimize my code I need it to be also in a Select, but without the entries whose type are 'field' nor 'map'

Yet, I get to choose from everything, even the entries which types are 'field' and 'map'. Is there a clean way to do it ?

1
  • 1
    please post your model columns Commented Nov 25, 2013 at 10:27

1 Answer 1

70

AngularJS NOT Filter

<select ng-model="test" ng-options="c as c.label group by c.type for c in columns
    | filter:{ type : '!field' }
    | filter:{ type : '!map' }">
</select>

Fiddle

From the docs:

"...The predicate can be negated by prefixing the string with !."

"A pattern object can be used to filter specific properties on objects contained by array. For example {name:"M", phone:"1"} predicate will return an array of items which have property name containing "M" and property phone containing "1"..."

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

1 Comment

Thanks this helped . Specifically the part about using the filter variable "type" as is . rather than c.type .

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.