### File

`src/lib/timeago.directive.ts`

### Metadata

Selector | `[rxapTimeago]`
Standalone | `true`
exportAs | `rxapTimeago`

### Index

###### Methods
setContent
###### Inputs
date live
###### Accessors
date live

### Inputs

date
Type : `string | number | Date`
Defined in src/lib/timeago.directive.ts:24
The Date to display. An actual Date object or something that can be fed to new Date.

live
Type : `boolean`
Defined in src/lib/timeago.directive.ts:32
If the directive should update itself over time

### Methods

setContent
`setContent(node: any, content: string)`
Defined in src/lib/timeago.directive.ts:36
Parameters :
Name | Type | Optional
node | `any` | No
content | `string` | No
Returns : `void`

### Accessors

date
set `date(date: string | number | Date)`
Defined in src/lib/timeago.directive.ts:24
The Date to display. An actual Date object or something that can be fed to new Date. Parameters :
Name | Type | Optional
date | `string | number | Date` | No
Returns : `void`

live
set `live(live: boolean)`
Defined in src/lib/timeago.directive.ts:32
If the directive should update itself over time Parameters :
Name | Type | Optional
live | `boolean` | No
Returns : `void`

    import {
      Directive,
      ElementRef,
      inject,
      Input,
    } from '@angular/core';
    import {
      coerceBoolean,
      IsDefinedAndNotNull,
    } from '@rxap/utilities';
    import { TimeagoFormatter } from './timeago.formatter';

    @Directive({
      selector: '[rxapTimeago]',
      exportAs: 'rxapTimeago',
      standalone: true,
    })
    export class TimeagoDirective {

      private readonly elementRef = inject(ElementRef);

      /** The Date to display. An actual Date object or something that can be fed to new Date. */
      @Input()
      set date(date: string | number | Date) {
        this.setContent(this.elementRef.nativeElement, TimeagoFormatter(date));
      }

      private _live = true;

      /** If the directive should update itself over time */
      @Input()
      set live(live: boolean) {
        this._live = coerceBoolean(live);
      }

      setContent(node: any, content: string) {
        if (IsDefinedAndNotNull(node.textContent)) {
          node.textContent = content;
        } else {
          node.data = content;
        }
      }

    }

# results matching ""

# No results matching ""