How do you pass an object to a directive? I'm trying to access users in my directive's scope without success. This is what I've tried:
In my controller I set an array of users to a scope:
$scope.users = payload.data.results;
Then I want to pass that object to my directive as an attribute:
<display test123='users'></display>
The directive function:
function ListDisplay() {
var directive = {
replace: 'true',
restrict: 'E',
scope: {
test123: '='
},
controller: ListDisplayController,
controllerAs: 'vm',
bindToController: true,
link: ListDisplayLinkFunc
};
return directive;
function ListDisplayController($scope) {
console.log($scope.test123);
}
function ListDisplayLinkFunc(scope, elem, attr) {
console.log(scope.test123);
}
}
But when I try to console out scope.data I get undefined.
test123and still get undefined. :(payloadinpayload.data.resultsis a promise?