For some reason, I am unable to access or locate the service even though I have successfully accessed it in other scripts before.
After injecting my service which includes the function to add a customer to the database, I am trying to access it within nested loops and conditional statements. However, I am facing an issue where even the injected firestore cannot be reached. I am completely clueless about why this is happening. Can anyone provide assistance?
constructor(
public service: CustomerService,
public firestore: AngularFirestore,
) { }
scanImage() {
console.log('>>>> Customer Scanning Image...');
for (let image = 0; image < this.images.length; image++) {
Tesseract.recognize(this.images[image]).then(
function(result) {
const newLine = result.text.split('\n');
for (let line = 0; line < newLine.length; line++) {
const word = newLine[line].split(' ');
if (word[word.length - 1] === '>') {
console.log(`>>>> time: ${word[0]}`);
console.log(`>>>> code: ${word[1]}`);
console.log(`>>>> name: ${word[2] + ' ' + word[word.length - 4]}`);
console.log(`>>>> total: ${word[word.length - 3]}`);
console.log(`>>>> status: ${word[word.length - 2]}`);
console.log('______________________\n');
const data: Customer = {
time: word[0],
code: word[1],
name: word[2] + ' ' + word[word.length - 3],
total: word[word.length - 2],
status: word[word.length - 1]
};
this.service.add(data);
}
}
});
}
}