I have some Angular 1.4 code I've inherited, which has some bizarre scope issues I'm trying to tidy up - and I'm stuck on a particular one.
I have an ES6 Class controller (Babelified) - in it, I have a method like this
save(data) {
this.validate(data);
.... do some more stuff
}
I also have a View and model and html and all that good stuff. In it I have a custom directive for radio buttons - like this
<radio onupdate="vm.save" data="model.myradio1" />
My Radio directive seems to have two bindings for onupdate & data
.directive('radio', () => {
return {
restrict: 'E',
replace: true,
templateUrl: 'radio',
scope: {
data: '=',
onupdate: '='
}
};
})
the template contains
ng-click="radio.onupdate($parent.data);" <-- This looks suspect but no idea what it does!
However - this then explodes in ways I wouldn't have expected:
this.validate is not a function
I can see how this happened - this now refers to the radio buttons scope. But how do I fix it? I'm pretty new to Angular.
scopeconfiguration and howonupdateis called from inside.thisto my controller rather than the directive scope?