i am submitting this as a feature rather than a bug because I can't find any mention of why it isn't supported (maybe you have a reason) or similar bug report.
So.. currently, I can't use filters inside conditional statement, like this:
{{ prop !== null ? (prop | myFilter) : 'no data' }}
i can however use method instead of filter:
{{ prop !== null ? myFilter(prorp) : 'no data' }}
well I can also handle null value in my filter and I get my data filtered, but why not support it also in ternary expression? :)
Example: https://jsfiddle.net/Ljressro/
Thanks <3
API wouldn't change.
The expression syntax is defined as (JavaScript expression) + (| filters)
. Filters can only be appended to valid JavaScript - bringing in filters into JavaScript is not going to happen.
You can already use $options.filters.myFilter(prop)
in JavaScript expressions.
Thanks @yyx990803
I'll suggest to add this in docs.
Most helpful comment
The expression syntax is defined as
(JavaScript expression) + (| filters)
. Filters can only be appended to valid JavaScript - bringing in filters into JavaScript is not going to happen.You can already use
$options.filters.myFilter(prop)
in JavaScript expressions.