import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'fan';
val ="Hi welcome to angular "
}
import { PipeTransform, Pipe } from '@angular/core';
@Pipe({
name : 'uxpipe'
})
export class Uxpipe implements PipeTransform{
transform(value : any ){
console.log(value);
}
}
compiler.js:2175 Uncaught Error: Template parse errors:
The pipe 'uxpipe' could not be found ("<div>
<p>{{[ERROR ->]val | uxpipe}}</p>
</div>"): ng:///AppModule/AppComponent.html@1:7
at syntaxError (compiler.js:2175)
at TemplateParser.parse (compiler.js:11388)
at JitCompiler._parseTemplate (compiler.js:25963)
at JitCompiler._compileTemplate (compiler.js:25951)
at compiler.js:25895
at Set.forEach (<anonymous>)
at JitCompiler._compileComponents (compiler.js:25895)
at compiler.js:25808
at Object.then (compiler.js:2166)
at JitCompiler._compileModuleAndComponents (compiler.js:25807)
D\w+D
答案 0 :(得分:1)
在app.module.ts
中声明自定义管道
import { Uxpipe } from './uxpipe.pipe';
.
.
@NgModule({
declarations: [
AppComponent,
Uxpipe,
.
.
]
})