How to use pipe in ts not HTML

前端 未结 4 1022
清歌不尽
清歌不尽 2021-02-02 12:33

I adding text into html element from ts

like this

this.legend.append(\'text\')
  .attr(\'x\', legendRectSize + legendSpacing)
  .attr(\'y\', legendRectSi         


        
4条回答
  •  Happy的楠姐
    2021-02-02 12:47

    import pipe in the component

    import { PipeName } from './pipename'
    

    include it in the provides

    @Component({
        selector: 'pipe-using-component',
        templateUrl: './pipe-using-component.html',
        providers: [
            PipeName
        ],
    })
    

    inject it in the constructor

    export class PipeUsingComponent {
      constructor(private pipeName: PipeName)
       }
    
       var requiredResult = this.pipeName.transform(passvalue);
    }
    

提交回复
热议问题