0

I am trying to create array like this:

vm.finished_tasks = [];

inside foreach:

(value.finished === 1) ? vm.finished_tasks[item.id].push(value) : '';

There are 2 foreach loop item is from main loop, value is from loop inside...

I want to be able to access from tamlate something like this:

{{ vm.finished_tasks[1] }}
2
  • vm.finished_tasks.push(value) Commented Nov 8, 2015 at 14:32
  • {{ vm.finished_tasks[1] | json }} Commented Nov 8, 2015 at 14:33

1 Answer 1

1

In your code

vm.finished_tasks[item.id].push(value)

means value of item.id index is an array and push that value into that array

But you never declared vm.finished_tasks[item.id] as array instead you declared only vm.finished_tasks as an array

If you wanna just print index of vm.finished_tasks

The try like this

vm.finished_tasks.push(value)

But you wanna push data in item.id index

Then try like this

if(!vm.finished_tasks[item.id])
  vm.finished_tasks[item.id]=[];

(value.finished === 1) ? vm.finished_tasks[item.id].push(value) : '';
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.