#PipeTransform ENUM
1 messages · Page 1 of 1 (latest)
But it's always better to use it directly in the view
How about <p>{{ item | taskType }}</p> ?
Your pipe is probably wrong
Remove some complexity to isolate the problem
@Pipe({
name: 'taskType',
})
export class TaskTypePipe implements PipeTransform {
constructor() {}
transform(type: TaskType): string {
switch (type) {
case TaskType.BMW:
return `Test BMW`;
case TaskType.MERCEDES:
return `Test Mercedes`;
case TaskType.VOLVO:
return `Test Volvo`;
default:
return 'Unknown task type';
}
}
}
public getEnumKeys(): string[] {
return Object.keys(TaskType);
}
Put a break point in the switch of your pipe to see what happens
Have you added the pipe to your view?
<p>{{ item | taskType }}</p>
How about the break point?
Try to make a Stackblitz cause it's hard to tell without the full context
@pale pecan electrochip asked you twice to use the pipe in the template, but there is no pipe used in your Stackblitz example.
Here is your working solution https://stackblitz.com/edit/angular-pgndqg-r2bdlh?file=src/app/button-toggle-mode-example.ts (not the best IMHO but it's working)
You forgot to declare your pipe in the module
Button toggle selection mode
Auto-generated from: https://material.angular.io
That's already done from the beginning for me.
If you expect something else, take more time to explain your expectations.