I have a form inside a nested directive (in an Ionic/Angular project)
<ion-content class="scroll-content ionic-scroll has-header">
<recipe-form>
<form id="example-form" action="#" class="ng-pristine ng-valid">
</form>
</recipe-form>
<div>
But I cannot access this for via jQuery.
I tried the following without success:
$(function () {
#$('#example-form')
#angular.element(document.querySelector('#example-form'))
#angular.element.find('#example-form')
#angular.element.find('example-form')
#angular.element(document.querySelector('example-form'))
}
I also have found several SO questions, and almost all of them are solved by using syntax angular.element(document.querySelector(<element id>))
But for me it gives a blank array []
I'm loading my js file in the head
section and after jQuery.
Update
However, this following method I have in the same file for button click works as expected
$( document ).ready(function() {
$(document).on('click', 'a.next', function(e){
arr = [];
arr = $('.card.recipe-slider');
current_card = $(this).closest('.card')[0];
id = current_card.dataset.id;
if (validateInput(current_card)){
$(arr[id]).addClass('active');
$(current_card).removeClass('active');
} else {
}
})
});