Skip to content

Instantly share code, notes, and snippets.

body {
margin: 0;
padding: 0;
font-family: "Work Sans", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.text-light .shadow {
box-shadow: 0 0.5rem 1rem rgba(255, 255, 255, 0.25) !important;
/*
*ngFor="let c of oneDimArray | sortBy:true/false:'asc'"
*ngFor="let c of arrayOfObjects | sortBy:true/false:'asc':'propertyName'"
*/
import { Pipe, PipeTransform } from "@angular/core";
import { orderBy, sortBy } from "lodash";
@Pipe({ name: "sortBy" })
export class SortByPipe implements PipeTransform {
transform<T>(
<div class="container mt-5 border rounded p-0">
<h1 class="bg-light text-center p-2">SMS TEMPLATE ENGINE</h1>
<div class="row p-3">
<div class="col-md-4">
<h3>Template</h3>
<textarea class="form-control" [formControl]="editorData"></textarea>
</div>
<div class="col-md-4">
<h3>Preview</h3>
<div class="preview bg-light rounded border p-2" [innerText]="templateText"></div>
import { Component, VERSION, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
import { Clipboard } from "@angular/cdk/clipboard";
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
<!-- 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>
<app-product [pData]="pList" (addItem)="saveToCart($event)"></app-product>
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
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);
}
import {getErrorMsg} from './error-messages';
const requiredValidator = (value) => {
return value !== '';
}
const minLengthValidator = (value, minlength) => {
return !(value.length < minlength);
}
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'],
})