angular пользовательских труб, не способных производить - PullRequest
0 голосов
/ 02 марта 2020
<div>
  <p>{{val | uxpipe}}</p>
</div>
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)

1 Ответ

1 голос
/ 02 марта 2020

Объявление пользовательской трубы в app.module.ts

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

@NgModule({
  declarations: [
    AppComponent,
    Uxpipe,
    .
    .
  ]
})
...