I've a simple directive
'use strict';
angular.module('ludaooApp')
.directive('rating', function () {
return {
templateUrl: 'app/rating/rating.html',
restrict: 'EA',
link: function (scope, element, attrs) {
scope.mark = attrs.mark;
console.log(attrs);
};
})
This directive only log the attributes of the directive.
Here is how I use that directive :
<rating mark="{{game.rating}}" style="font-size: 30px"></rating>
And here is the result of the web inspector :
As you can see, mark is empty mark="" on the first line. But after, it is filled in with its value mark="4.16".
The result is that if I console.log(scope.mark), I see 0 instead of 4.16.
I think it's because the 4.16 is retrieved from the database and, the code is executed before that {{game.rating}} is initialized in the controller.
So the question is, how to deal with this problem ? And how to access to the "4.16" ?

game.ratingat the time of rendering the directive.But the value you find in dev console is the current value of mark evaluated after logging in the console. If you hover near theiyou will find that message.scope: { mark: '=' }to your directive. Add it afterrestrict: 'EA'(although order doesn't matter).$watchon themarkand check if value is greater than 0 and then do something likeconsole.log(value)