角度定制管道无法产生输出

时间:2020-03-02 07:47:58

标签: angular typescript angular-pipe

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

1 个答案:

答案 0 :(得分:1)

app.module.ts中声明自定义管道

import { Uxpipe } from './uxpipe.pipe';
.
.

@NgModule({
  declarations: [
    AppComponent,
    Uxpipe,
    .
    .
  ]
})
相关问题