Sorry if the title is not the most accurate..
So what I'm trying to do and what are my reasons behind it. I have a list of entries which can be pretty huge, up to 400 items, I get this list from ajax request, now if the first item has attribute running
I want to extract it from the list(by using splice()
) and pass it to a directive, which can work on it in an isolated scope. Why? Because the running entry will have a timer on it, which adds +1 to one of it's attributes each second with $timeout
.
Now I want it to be isolated because of this Angular.js filters and functions on scope that is changing every second I don't want filters and everything on the list of not-running entries to be called every second just because something(timer especially) changed on the running entry.
Now when I press save or something, I want to put the running entry back to the entries, only with running: false
now.
I kind of know how to inherit object from parent and create an isolated scope from it on the directive - http://plnkr.co/edit/zq3urVh5t6N12T5ZrViO?p=preview
Passing it there this way doesn't really seems ideal, but I was told it was fine and nothing really against best practice.
Now here comes the problems/question
- Is there any way to pass "running" the directive without adding it to the scope, because it's pretty much useless there once it gets copied
- should I look for a way of passing it without adding it to the scope?
- or should I deleted it after its copied?
- or should I leave it because it doesn't matter?
- if
ENTRIES
are being set with ajax, it's impossible to copy the running one, because it's not yet set - http://plnkr.co/edit/vH3hKbkTkTvcHqykIXDt?p=preview- should I have
$watch
inside the directive? - or should I use broadcast/on? like this http://plnkr.co/edit/1oPMyxSVMdiN8tB9l1YJ?p=preview
- or am I doing it wrong completely?
- should I have
Thanks!