I get the error:
EXCEPTION: value.indexOf is not a function
whenever I try to use a javascript function. Here is the code:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'id'
})
export class IdPipe {
transform(value: string): string {
let start = value.indexOf('"id": "')
let id = value.substring(start + 7, start + 7 + 36);
return id;
}
}
What do I need to do to make this work? I see similar examples in other people's code, so I think this should work.
console.log(typeof value);valueis something that does not have anindexOfproperty. You canconsole.log(typeof value)before that to see what's going on.