I'm using AngularJS and Ionic in a project, and I wanted to try creating directives.It doesn't shows up any error or warning message, but it also does not executes the directive's function. Right now, my code is pretty much this, Here is the js file:
angular.module('wingz').directives('preventSubmit',function(){
return {
restrict: 'A',
link: function(scope,element,attr){
console.log('in directive');
element.bind('submit',function(e){
if(!element.$valid){
e.preventDefault();
console.log(element.child);
}
});
}
}
});
and here is the html:
<form name="form" class="credit-card-form" prevent-submit ng-submit="doAddCard()">
It's already loaded in the index.html file and I haven't use the scope déclaration in it because I want to use the parent scope. Is anybody already had a problem like that I'll be glad to hear about because this is driving me crazy ...
Thanks a lot
it should be angular.module('wingz').directive('preventSubmit', function() { ... }) not .directives
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With