This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Isolate scope binding to parent function inconsistent context #8552
Closed
Description
When using an isolated scope, I find myself having to return a bound function from a &
isolated scope binding, or the this
becomes undefined or Window DOM.
<div ng-controller="MyCtrl as mycontroller">
<div some-directive="mycontroller.func"></div>
<div ng-click="mycontroller.func()">Regular ngClick</div>
</div>
.controller('MyCtrl', function(){
this.func = function(){ console.log(this); };
})
.directive('someDirective', function(){
return {
restrict: 'A',
scope: { 'fn': '&someDirective' }
link: function(scope){
scope.doh = function(){
scope.fn()();
};
}
};
});