This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, EventEmitter, Input, Output, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core'; | |
@Component({ | |
selector: 'display', | |
templateUrl: './display.component.html', | |
styleUrls: ['./display.component.css'], | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class DisplayComponent { | |
constructor(private changeDetectorRef: ChangeDetectorRef) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const displayRoute: RouteData<DisplayComponent> = { | |
path: 'RouteComponentExample/:route_id', | |
component: RouteComponent, | |
data: { | |
component: { | |
type: DisplayComponent, | |
inputs: { | |
inputData: `This is populated with static data from our 'inputs' property in route data` | |
}, | |
outputs: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const displayRoute: RouteData<DisplayComponent> = { | |
path: 'RouteComponentExample/:route_id', | |
component: RouteComponent, | |
data: { | |
component: { | |
type: DisplayComponent, | |
inputs: { | |
inputData: `This is populated with static data from our 'inputs' property in route data` | |
}, | |
outputs: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const omit = (originalObject = {}, keysToOmit = []) => { | |
const clonedObject = { ...originalObject }; | |
for (const path of keysToOmit) { | |
delete clonedObject[path] | |
} | |
return clonedObject; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const omit = (originalObject = {}, keysToOmit = []) => { | |
const clonedObject = _.cloneDeep(originalObject); | |
for (const path of keysToOmit) { | |
_.unset(clonedObject, path) | |
} | |
return clonedObject; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const omit = (originalObject = {}, keysToOmit = []) => { | |
const clonedObject = { ...originalObject }; | |
for (const path of keysToOmit) { | |
_.unset(clonedObject, path) | |
} | |
return clonedObject; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const omit = (originalObject: object, keys: string[]) => _.pickBy(objectFromFrontend, (value, key) => !keys.includes(key)) | |
const objectFromFrontend = { | |
_id: 5, | |
data: { | |
some: 1, | |
useful: 2, | |
data: 3 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const objectFromFrontend = { | |
_id: 5, | |
data: { | |
some: 1, | |
useful: 2, | |
data: 3 | |
} | |
} | |
const objectToInsertIntoDB = _.pick(objectFromFrontend, ['data.useful', 'data.data']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const omit = (keysToOmit: string[], originalObj = {}) => | |
Object.fromEntries( | |
Object.entries(originalObj) | |
.filter(([key]) => !keysToOmit.includes(key)) | |
) | |
const objectFromFrontend = { | |
_id: 5, | |
data: { | |
some: 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const omit = (keyToOmit: string, { [keyToOmit]: _, ...omittedPropObj } = {}) => omittedPropObj; | |
const objectFromFrontend = { | |
_id: 5, | |
data: { | |
some: 1, | |
useful: 2, | |
data: 3 | |
} | |
} |
NewerOlder