I am not able to use 'ng-change' in one of my custom AngularJS directives

108 Views Asked by At

ParentPage.html

<records-grid-column ng-change="validateData()" ng-model="name">                     
        {{item.name}}  </records-grid-column>  

Directive controller

   directive = {
    restrict: 'E',
    controller: ABCD,
    scope: {
        ngModel:'=',
        ngChange:'&',
        class:'='
    },
    transclude: true,
    replace: true,
    template: '<td class></td>'
};

return directive;

Edit - I changed Modal to model but still i am getting same error ...

Function validateData() is on parent page but on page load i am getting this error - 'Error: [Error] [$compile:ctreq] Controller 'ngModel', required by directive 'ngChange', can't be found!'

I tried everything but not able to resolve the issue, overall i just to want to call a function to validate the data after its edited and for that i am using 'ngChange'. Please let me know where i am wrong, Would be very thankful for help :)

1

There are 1 best solutions below

1
On BEST ANSWER

Change

From

  scope: {
        ngModal:'=',
        ngChange:'&',
        class:'='
    }

To

scope: {
    ngModel:'=',
    ngChange:'&',
    class:'='
}