我无法弄清楚隔离范围是如何工作的。当我评论指令的范围部分时,我的代码似乎工作正常。谁能解释我错过了什么?
export function ExampleDirective() {
'ngInject';
let directive = {
restrict: 'E',
templateUrl: 'someurl.html',
scope: {
theFilter: '=' //isolated - if i make the scope global, it works
},
controller: ExampleController,
controllerAs: 'vm',
bindToController: true,
link: linkFunc
};
function linkFunc(scope, el, attr, vm) {
}
return directive;
}
class SymptomSearchController {
constructor ($scope) {
'ngInject';
}
}
<input type="text"
class="form-control"
ng-model="theFilter">
<example-directive theFilter="main.theFilter"></example-directive>
export class MainController { //as 'main'
constructor() {
'ngInject';
this.theFilter = "test";
}
}