Ich habe eine einfache Richtlinie:Isolierte Richtlinie Bindung an Eltern Funktion
let directive = {
restrict: 'EA',
templateUrl: 'app/components/video-player/video-player.html',
scope: {
someFunction:'='
},
...
}
template:
<div class="video" ng-click="vm.someFunction(vm.someId)"></div>
directive:
<video-player some-function="main.ctaClick"></video-player> //controllerAs main
export class MainController {
...
someFunction(){
// How do I get the correct this here without using $parent?
let context = this.scope.$parent.main;
}
}
Im Grunde frage ich mich, ob es einen Weg gibt, den Kontext eines übergeordneten Bereich als Zwei-Wege-Bindung eine Funktion wie diese zu benutzen? Ist das der richtige Weg?