0
I’m making a link on a page that will redirect according to the object data. So I made a ternary condition, but it’s giving a syntax error and I can’t see what’s wrong:
My html:
<a class="article-home-small" ui-sref="obj.content_type == 'article' ? article({uid: obj.uid, title: slug(obj.title)}) : article_blog({uid: obj.uid, title: slug(obj.title)})">
The mistake:
Syntax Error: Token ')' is an unexpected token at column 39 of the expression [{uid: obj.uid, title: slug(obj.title)}) : article_blog({uid: obj.uid, title: slug(obj.title)}] starting at [) : article_blog({uid: obj.uid, title: slug(obj.title)}].
Made this mistake:
Error: Invalid state ref ''
without even me clicking on anything.– Vinicius Morais
Try using a function instead
ui-sref
and puts in theng-click
. The function receivesobj
as a parameter and then make the logic you need before sending to the right page.– Leo Brescia