in html i call my directive with: <div godata-pagination count="{{pagination.count}}" size="{{pagination.size}}" page="{{pagination.page}}"></div>
then my directive looks inside:
function link(scope, element, attrs) {
console.log('attrs: ' + attrs.size);
scope.pagCount = attrs.count;
scope.pagPage = attrs.page;
}
return {
restrict: 'A',
transclude: true,
scope: {
count: '@',
size: '@',
page: '@'
},
templateUrl: 'partials/godata/pagination.html',
link: link
};
In the partial (partials/godata/pagination.html) i can access these variables (count, size and page). For 100% in partial i access originaly these three variables, no other in this scope.
But i will do something with these variables in function link. If i try to access these variables in function link through attrs, they are empty :(
What is wrong and/or what can i do?
UPDATE:
And with scope: false
scope variable is undefined.
And why brings the line attrs.$observe('page', function(val) { console.log('$observe: ' + val); });
in function link two output ...one with and one without value?
UPDATE again:
function link(scope, element, attrs) {
console.log('scope: ' + scope.size);
console.log('scope: ' + scope);
console.log('attrs: ' + attrs.size);
console.log('attrs: ' + attrs);
attrs.$observe('size', function(size) {
console.log('$observe: ' + size);
if(size) {
scope.pagSize = size;
}
});
console.log('after observe; pagSize: ' + scope.pagSize);
}
...bring me:
But scope.pagSize
has a value in browser.
How can i work with these attributes in my directive, if i can't access them?!
scope: [object Object]
andattrs: [object Object]
– bitkorn