I am facing an issue with a directive in AngularJS.
return {
restrict: _restrict,
link: function (scope, element, attrs) {
$timeout(LinkPre, 0); //Calling a scoped method
},
templateUrl: ConstrutorapiTemplatesChart,
scope: "@",
controller: Controller
}
The LinkPre function I am using is as follows:
var LinkPre = function (scope, elem, attrs) {
attrs.$observe(_attrUrl, function (relatorio) {
if (relatorio != "") AoMudarUrl(scope, elem, relatorio);
});
}
However, I encountered an error stating that the attrs variable is undefined.
It says: Cannot read property '$observe' of undefined.
Does anyone have any insight into why this might be happening?
Note: It is important for me that the Link function is executed after the directive is rendered.