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;
}
}
基本上我想知道是否有使用父范围的情况下一种方式,当双向绑定这样的功能?这是正确的方法吗?