1
我有一個簡單的指令:隔離指令結合於母公司的功能
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;
}
}
基本上我想知道是否有使用父範圍的情況下一種方式,當雙向綁定這樣的功能?這是正確的方法嗎?