'How to slice letters from string with angular pipe?
When I get Promise error, it consists of a lot of letters so I want to shorten it with a pipe, but error doesn't show. Why?
Service:
error: any;
async register(email: string, password: string) {
try {
await this.afs.signInWithEmailAndPassword(email, password);
} catch (err:any) {
this.error = err;
}
}
TS:
err:any;
register() {
this.auth.register('email', 'password');
this.err = this.auth.error;
}
HTML:
<mat-error>{{err}}</mat-error>
This code is working but with pipe transform it not working:
@Pipe({name: 'error'});
export class FormErrorPipe implements PipeTransform {
transform(value: string): any {
if (value) {
return value.slice(10)
}
return null;
}
}
<mat-error>{{err | error}}</mat-error>
Any solution? Thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
