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 } from '@angular/core'; | |
| import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | |
| @Component({ | |
| selector: 'form', | |
| templateUrl: './form.component.html', | |
| styleUrls: ['./form.component.scss'] | |
| }) | |
| export class Form { | |
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
| <form [formGroup]="form"> | |
| <input type="password" | |
| formControlName="password"> | |
| <p class="help is-danger" | |
| *ngIf="form.get('password').hasError('strong')"> | |
| Must have at least one number, one lowercase and one uppercase letter.</p> | |
| </form> |
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 } from '@angular/core'; | |
| @Component({ | |
| selector: 'form', | |
| templateUrl: ` | |
| <form> | |
| <input type="checkbox" (click)="selected($event)" | |
| </form>`, | |
| styleUrls: ['./form.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
| function findAndRemove(array, item) { | |
| const index = array.indexOf(item); | |
| if(index>-1) { | |
| array.splice(index, 1); | |
| } | |
| return array; | |
| } |
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
| function isInputValid(value, type) { | |
| let valid; | |
| let errorTxt; | |
| switch(type) { | |
| case 'email': | |
| valid = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(value); | |
| errorTxt = 'Enter a valida email'; | |
| break; | |
| case 'phone': | |
| valid = /^([-0-9.()+ ]{5,50})*$/.test(value); |
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 } from '@angular/core'; | |
| import { FormBuilder, FormGroup } from '@angular/forms'; | |
| @Component({ | |
| selector: 'form', | |
| templateUrl: ` | |
| <form [formGroup]="form"> | |
| <input type="text" formControlName="name"> | |
| </form> | |
| `, |
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'; | |
| @Injectable() | |
| export class SecurityService { | |
| constructor() { } | |
| sanitizeAllTags(text:string) { | |
| return text.replace(/<[^>]*>/g, '*'); | |
| } |
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, EventEmitter, Output, ElementRef, ViewChild } from '@angular/core'; | |
| @Component({ | |
| selector: 'form-place', | |
| template: `<div #gmap>You got me!</div>`, | |
| styleUrls: ['./form-place.component.scss'] | |
| }) | |
| export class elementComponent implements OnInit { | |
| @ViewChild("gmap", {read: ElementRef}) gmap: ElementRef; |
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 } from '@angular/core'; | |
| import { FormGroup, FormBuilder } from '@angular/forms'; | |
| import { } from '@types/googlemaps'; | |
| @Component({ | |
| selector: 'autocomplete', | |
| template: ` | |
| <input class="input" | |
| type="text" | |
| [(ngModel)]="autocompleteInput" |
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
| /** | |
| * wraps a promise in a timeout, allowing the promise to reject if not resolve with a specific period of time | |
| * @param {integer} ms - milliseconds to wait before rejecting promise if not resolved | |
| * @param {Promise} promise to monitor | |
| * @Example | |
| * promiseTimeout(1000, fetch('https://courseof.life/johndoherty.json')) | |
| * .then(function(cvData){ | |
| * alert(cvData); | |
| * }) | |
| * .catch(function(){ |
OlderNewer