I'm struggling with accessing data using a directive, especially when I have defined my models like this:
vm = this;
vm.myModel = "hello";
Here is an example of my directive:
function mySelectedAccount(){
return {
restrict: 'A',
link: function(scope, element, attrs) {
element.on('click', function() {
console.log(scope.myModel);
});
}
}
}
Because I'm not using $scope, how can I access the "myModel" defined inside my controller within the directive? When trying to access it using the scope parameter in my directive, I receive undefined.
Thank you for your assistance