Thanks for your patience here, I\'m just starting out with TypeScript.
I\'m working on an angular 2 app that needs to accept text inputs and then make a bunch of calcul
Faced a similar type of query and worked for me.
My case:
article Id
comes in the string format from route params and from API I get the data in number format.
If I check with !=, ES lint throws an error. So I am converting a string to number in vanilla javascript using Number() method.
const articleId = Number(this.route.snapshot.params['articleId']);
data.forEach((element, index) => {
// console.log(typeof(element['id']), element['id']);
// 4, number
// console.log(typeof(this.route.snapshot.params['articleId']), this.route.snapshot.params['articleId']);
// 4, string (converted to number)
if (element['id'] !== articleId) {
//my implementation
}
}
Reference Link: