UPDATE
My controller loads data from two services, and the directive is linked before one of the services has returned data. So I think I need to find a way to prevent loading the directive until the variable from the second service has actually been populated.
What is the best way to handle that?
Original question:
I have a scope with an array of objects, and also a single integer. So, in the controller, something like this:
$scope.array = [
{title: 'foo', first: 'spam', second: 'eggs'},
{title: 'bar', first: 'maps', second: 'sgge'}
];
$scope.another = 400;
I am using ngRepeat to pass values from each object in the array to a directive, like so:
<div ng-repeat="a in array"
my-directive="a.title"
my-first-val="a.first"
my-second-val="a.second"></div>
I would also like to bind another value, which is the same for all instances of the directive, but may also change:
<div ng-repeat="a in array"
my-directive="a.title"
my-first-val="a.first"
my-second-val="a.second"
another-val="another"></div>
This final value never seems to bind properly [actually, it didn't bind because it hadn't populated yet - the syntax used here is fine]. Is this possible? Is there another way to bind a single value to all instances of a directive using ngRepeat?