I have some data called foo
which lives in a scope which is parent to three children:
<div ng-init="foo=[1, 2, 3]">
<bar foo="{{foo}}" baz="{{odp}}" />
<mpq foo="{{foo}}" bats="{{maktz}}" />
<ktr foo="{{foo}}" otr="{{ompg}}" />
</div>
bar.scope = {foo: '=', baz: '@'};
mpq.scope = {foo: '=', bats: '@'};
ktr.scope = {foo: '=', otr: '@'};
What is the best way to share foo
between those three directives? Options include:
- Use an isolated scope to pass in
foo
three times, thereby duplicating it across four scopes - Have the child directives inherit the parent scope, and find
baz
,bats
, orotr
onattrs
- Put
foo
on the$rootScope
and inject that into the child directives
Or is there another approach that is better?