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 { Pipe, PipeTransform } from '@angular/core'; | |
| @Pipe({name: 'slugify'}) | |
| export class SlugifyPipe implements PipeTransform { | |
| transform(input: string): string { | |
| return input.toString().toLowerCase() | |
| .replace(/\s+/g, '-') // Replace spaces with - | |
| .replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
| .replace(/\-\-+/g, '-') // Replace multiple - with single - | |
| .replace(/^-+/, '') // Trim - from start of text |
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 { FormControl, FormGroup } from '@angular/forms'; | |
| export class PasswordValidator { | |
| // If our validation fails, we return an object with a key for the error name and a value of true. | |
| // Otherwise, if the validation passes, we simply return null because there is no error. | |
| static areNotEqual(formGroup: FormGroup) { | |
| let firstControlValue: any; | |
| let valid = true; |
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 { Injectable } from '@angular/core'; | |
| import { CardItem } from 'src/app/shared/card-helpers/card-item.model'; | |
| import { PostCardComponent } from 'src/app/shared/card-templates/post-card/post-card.component'; | |
| import { ProductCardComponent } from 'src/app/shared/card-templates/product-card/product-card.component'; | |
| import { QuoteCardComponent } from 'src/app/shared/card-templates/quote-card/quote-card.component'; | |
| @Injectable() | |
| export class HomeService { | |
| public getItems(): CardItem[] { | |
| return [ |
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
| //Complete example for Ionic Framework in: https://ionicthemes.com/tutorials/about/forms-and-validation-in-ionic | |
| //Complete example for Angular in: https://angular-templates.io/tutorials/about/angular-forms-and-validations | |
| import { AbstractControl, ValidatorFn } from '@angular/forms'; | |
| import * as libphonenumber from 'google-libphonenumber'; | |
| export class PhoneValidator { | |
| // Inspired on: https://github.com/yuyang041060120/ng2-validation/blob/master/src/equal-to/validator.ts | |
| static validCountryPhone = (countryControl: AbstractControl): ValidatorFn => { |
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 { FormControl, FormGroup } from '@angular/forms'; | |
| export class PasswordValidator { | |
| static areEqual(formGroup: FormGroup) { | |
| let val; | |
| let valid = true; | |
| for (let key in formGroup.controls) { | |
| if (formGroup.controls.hasOwnProperty(key)) { | |
| let control: FormControl = <FormControl>formGroup.controls[key]; |
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 { PasswordValidator } from '../../validators/password.validator'; | |
| this.matching_passwords_group = new FormGroup({ | |
| password: new FormControl('', Validators.compose([ | |
| Validators.minLength(5), | |
| Validators.required, | |
| Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$') //this is for the letters (both uppercase and lowercase) and numbers validation | |
| ])), | |
| confirm_password: new FormControl('', Validators.required) | |
| }, (formGroup: FormGroup) => { | |
| return PasswordValidator.areEqual(formGroup); |
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
| # Specifies intentionally untracked files to ignore when using Git | |
| # http://git-scm.com/docs/gitignore | |
| *~ | |
| *.sw[mnpcod] | |
| *.log | |
| *.tmp | |
| *.tmp.* | |
| log.txt | |
| *.sublime-project |
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
| { | |
| "controls": [ | |
| { | |
| "name": "address1", | |
| "label": "Address line 1:", | |
| "value": "", | |
| "type": "text" | |
| }, | |
| { | |
| "name": "address2", |
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
| { | |
| "controls": [ | |
| { | |
| "name": "firstName", | |
| "label": "First name:", | |
| "value": "", | |
| "type": "text" | |
| }, | |
| { | |
| "name": "lastName", |
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
| <ng-container *ngFor="let control of jsonFormData?.controls"> | |
| <label class="block mt-6" for="{{ control.name }}">{{ | |
| control.label | |
| }}</label> | |
| <input | |
| *ngIf=" | |
| [ | |
| 'text', | |
| 'password', | |
| 'email', |
NewerOlder