This file contains hidden or 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 createObject=(custom_schema,missingKeys,data)=>{ | |
const newObj=Object.create({}); | |
// add available keys | |
for(let key of Object.keys(custom_schema)){ | |
const k=custom_schema[key]; | |
newObj[k]=data[key]; | |
} | |
// add missing keys | |
for(let k of missingKeys){ | |
newObj[k]=''; |
This file contains hidden or 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 reMapAll=(custom_schema,missingKeys,data:any)=>{ | |
const newArray=[] | |
for(let d of data){ | |
newArray.push(createObject(custom_schema,missingKeys,d)); | |
} | |
return newArray; | |
} |
This file contains hidden or 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 cars=['Audi','Merc','BMW','Volvo','Tesla'] --> | |
<ul> | |
<li *ngFor="let car of cars">{{car}}</li> | |
</ul> |
This file contains hidden or 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
/* | |
*ngFor="let c of oneDimArray | sortBy:'asc'" | |
*ngFor="let c of arrayOfObjects | sortBy:'asc':'propertyName'" | |
*/ | |
import { Pipe, PipeTransform } from '@angular/core'; | |
import { orderBy } from 'lodash'; | |
@Pipe({ name: 'sortBy' }) | |
export class SortByPipe implements PipeTransform { |
This file contains hidden or 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, OnInit, AfterViewInit, ViewChild, ElementRef } from '@angular/core'; | |
import { environment } from 'src/environments/environment'; | |
import { LocationService } from 'src/app/core/services/location.service'; | |
import { ModalController } from '@ionic/angular'; | |
@Component({ | |
selector: 'app-location-picker', | |
templateUrl: './location-picker.component.html', | |
styleUrls: ['./location-picker.component.scss'], | |
}) |
This file contains hidden or 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 {getErrorMsg} from './error-messages'; | |
const requiredValidator = (value) => { | |
return value !== ''; | |
} | |
const minLengthValidator = (value, minlength) => { | |
return !(value.length < minlength); | |
} |
This file contains hidden or 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 errorMessages = { | |
required: () => 'This field is required', | |
pattern: () => 'Incorrect format', | |
minlength: (param) => `Min chars required is ${param.requiredLength}`, | |
maxlength: (param) => `Max chars allowed is ${param.requiredLength}` | |
}; | |
export const getErrorMsg = (err, errObj) => { | |
return errorMessages[err](errObj); | |
} |
This file contains hidden or 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 React from 'react'; | |
import PropTypes from 'prop-types'; | |
import { checkErrors } from './validation-service'; | |
// import {Text} from 'react-native' // only for react-native app | |
class ShowErrors extends React.Component { | |
static propTypes = { | |
value: PropTypes.any, | |
validations: PropTypes.object, | |
display: PropTypes.bool |
This file contains hidden or 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
<app-product [pData]="pList" (addItem)="saveToCart($event)"></app-product> |
This file contains hidden or 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
<!-- TEMPLATE FORMS --> | |
<input type="text" name="name" ngModel required #nameRef="ngModel" /> | |
<app-show-errors [ctrl]="nameRef"></app-show-errors> | |
<!-- REACTIVE FORMS --> | |
<input type="text" formControlName="mycontrol"/> | |
<app-show-errors [ctrl]="formGroupObj.get('mycontrol')"></app-show-errors> |