0

Basically I have a list like this :

Apples - 1
Oranges - 2
Pears - 0

I want to turn the quantity of fruits in something like this, when it is 0 it should print none, a few when it is 1 and a lot when it is 2.

Apples - a few
Oranges - a lot
Pears - none

So I've created on array

$scope.quantityToString = ["none", "a few", "a lot"];

And try to render this in HTML

{{ quantityToString [ {{ quantity }} ] }}

But it is not working.

Is there any way how to get it work? Thanks in advance!

1 Answer 1

4

You don't need {{ }} inside []. Think of quantityToString[quantity] expression as normal javascript code. So it should be:

{{ quantityToString[quantity] }}
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.