I have a javascript file that contains some data manipulation functions (No DOM manipulation at all) such as float rounding, mathematical operations, ...etc
my js file called myexample.js looks like that
function example(input) {
return input * 2
}
module.exports = { example: example }
and then I have my angular component example.component.ts
for example:
import { Component, EventEmitter} from '@angular/core';
@Component({
selector: 'input-number',
template: `<input
type='text'
[(value)]='value'
(blur)='runExample()'
/>`,
inputs: ['value'],
outputs: ['valueChange']
})
export class Example {
value: string;
valueChange = new EventEmitter;
runExample() {
let val = parseFloat(this.value);
// here i need to call example(input) from myexample.js
// and assign the return to val
this.valueChange.emit(val);
}
I have been searching for quite a while now and tried multiple things but unfortunately with no luck at all.
I would be really grateful if someone can help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…