Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Latest commit

 

History

History
95 lines (69 loc) · 1.33 KB

object.md

File metadata and controls

95 lines (69 loc) · 1.33 KB

Object

You can check the module import here.

keys

Returns the array of keys of the given object or array.

File
import { NgKeysPipeModule } from 'angular-pipes';
Usage
const value = {
  a: 1,
  b: 2,
  c: 3,
};
{{ value | keys }}
<!-- ['a', 'b', 'c'] -->
{{ [1, 2, 3] | keys }}
<!-- ['0', '1', '2'] -->

toArray

Transforms an object to an array

File
import { NgToArrayPipeModule } from 'angular-pipes';
Usage
const value = {
  a: 1,
  b: 2,
  c: 3,
};
{{ value | toArray }}
<!-- [1, 2, 3] -->

defaults

Apply defaults value to an object or an object in an array.

When applied to an array, the non object values will be left unchanged. The nulls and undefineds will be changed to the defaults.

File
import { NgDefaultsPipeModule } from 'angular-pipes';
Usage
const d = {
  a: 1,
  b: 2,
  c: 3,
};

const object = {
  a: 2,
};

const array = [{ a: 2 }, null, { b: 3 }, undefined];
{{ object | defaults: d }}
<!-- { a: 2, b: 2, c: 3 } -->
{{ array | defaults: d }}
<!-- [{ a: 2, b: 2, c: 3 }, { a: 1, b: 2, c: 3 }, { a: 1, b: 3, c: 3 }, { a: 1, b: 2, c: 3 }]-->