我正在尝试在Angular 2中使用TypeScript将一个数字值转换为字符串,该操作在管道内进行。但是报错:
Type string is not assignable to type number
我的管道如下所示:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'pxsuffix'
}) export class pxsuffix implements PipeTransform {
transform(input: number): number {
if ((input > 0)) {
input = input.toString(),
}
return (
input = input + 'px',
);
}
}