ng-vdom icon indicating copy to clipboard operation
ng-vdom copied to clipboard

Feature: pipe support in render function

Open trotyl opened this issue 6 years ago • 0 comments

Integrate Pipes with render function.

API Design

function pipe(type: Type<any>): (value: any, ...extras: any[]) => never
  • type: the pipe class;
  • value: the value passed to pipe;
  • extras: additional parameters passed to pipe;

Example

import { AsyncPipe, DatePipe } from '@angular/common'
import { pipe, Renderable } from 'ng-renderable'

const async = pipe(AsyncPipe)
const date = pipe(DatePipe)

@Component()
class MyComponent extends Renderable {
  @Input() title: Observable<string>
  @Input() date: Date

  render() {
    return (
      <p title={ async(this.title) }>
        { date(this.date, 'fullDate') }
      </p>
    )
  }
}

trotyl avatar Dec 26 '18 07:12 trotyl