I have one custom query function written in a javascript file under the source folder (i.e. /src/assets/inlineedit.js) of Angular application.
Here's the content of the file.
$.fn.inlineEdit = function(replaceWith, connectWith) {
$(this).hover(function() {
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
$(this).click(function() {
var elem = $(this);
elem.hide();
elem.after(replaceWith);
replaceWith.focus();
replaceWith.blur(function() {
if ($(this).val() != "") {
connectWith.val($(this).val()).change();
elem.text($(this).val());
}
$(this).remove();
elem.show();
});
});
};
Now, I want to call this function within Angular mycomponent.ts file and content looks as below:
import { Component, ViewChild, ElementRef } from '@angular/core';
@Component({
selector: 'app-pivotgrid',
templateUrl: './mycomponent.component.html',
styleUrls: ['./mycomponent.component.css']
})
export class mycomponent {
OnCellclick (event): void
{
var replaceWith = $('<input name="temp" type="text" />'),
connectWith = $('input[name="hiddenField"]');
$('#innerDiv').inlineEdit(replaceWith, connectWith);
}
}
But, I'm getting error like
Property 'inlineEdit' does not exist on type 'JQuery'
How to call jQuery functions inside Angular components?