1

I've made an implementation of vue.js in an .net-core mvc project which will return data from a controller. So let's say that the result is:

[{"id":1,"uniqueStr":"string1","ttlValue":"something","hlpValue":"something2"},{"id":2,"uniqueStr":"string2","ttlValue":"something","hlpValue":"something2"}]

I can get the row value with a snippet like:

{{ data[0] }}

So I have two things remaining. The situation is, I need the rows on one page without a loop. So my question would be:

How can I get the "ttlValue" of the row where the "uniqueStr" would be "string2".

I thinking something in the line of but that obviously doesn't function: {{ data[0][1] }}

1 Answer 1

1

I would do it with a computed value, like this. If you need to pass a parameter, you can use a method instead, like this.

I'm not sure what you meant with without a loop though. My solution loops through the object with .filter and with your current data structure, it's not really doable more directly.

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

2 Comments

Ah I see, that is indeed a method. I'll see if I can adjust specificValue() to accept a variable then it would be perfect
I added an example with passing a parameter - the code is nearly identical, you just use methods instead of computed.

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.