When working with Angular directives, I am aware that I can assign an isolated scope by adding '=' or '@' or '&' in the {} to define variables. However, it seems like this is not required within the link function. For example:
scope: {
foo:'=foo',
bar:'@bar'
}
This setup works as expected.
link: function($scope, $element){
$scope.foo = 'foo';
$scope.bar = 'bar';
}
Even though the link function is inside the directive, the above code functions perfectly fine.
scope: {
foo:'foo',
bar:'bar'
}
However, without adding '=' or '@' or '&', defining variables does not work as intended.
My question is, why is it possible to define variables within the link function without the need for '=' or '@' or '&' when both $scope and $scope:{} represent the same isolated scope?
Thank you!!!