Skip to content

Instantly share code, notes, and snippets.

View CharlieGreenman's full-sized avatar
🔎
To push or pull that’s the question, but never the answer.

Charlie Greenman CharlieGreenman

🔎
To push or pull that’s the question, but never the answer.
View GitHub Profile
"build": {
...
"configurations": {
...
"fr": {
"aot": true,
"outputPath": "dist/my-project-fr/",
"i18nFile": "src/locale/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
<trans-unit id="972cb0cf3e442f7b1c00d7dab168ac08d6bdf20c" datatype="html">
<source>Updated: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></source>
<target>Mis à jour: <x id="ICU" equiv-text="{minutes, plural, =0 {...} =1 {...} other {...}}"/></target>
</trans-unit>
<trans-unit id="7151c2e67748b726f0864fc443861d45df21d706" datatype="html">
<source>{VAR_PLURAL, plural, =0 {just now} =1 {one minute ago} other {<x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes ago by {VAR_SELECT, select, male {male} female {female} other {other} }} }</source>
<target>{VAR_PLURAL, plural, =0 {à l'instant} =1 {il y a une minute} other {il y a <x id="INTERPOLATION" equiv-text="{{minutes}}"/> minutes par {VAR_SELECT, select, male {un homme} female {une femme} other {autre} }} }</target>
</trans-unit>
<trans-unit id="f99f34ac9bd4606345071bd813858dec29f3b7d1" datatype="html">
<source>The author is <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></source>
<target>L'auteur est <x id="ICU" equiv-text="{gender, select, male {...} female {...} other {...}}"/></target>
</trans-unit>
<trans-unit id="eff74b75ab7364b6fa888f1cbfae901aaaf02295" datatype="html">
<source>{VAR_SELECT, select, male {male} female {female} other {other} }</source>
<target>{VAR_SELECT, select, male {un homme} female {une femme} other {autre} }</target>
</trans-unit>
ngOnInit() {
this.myForm = this.fb.group({
name: ['', Validators.required],
email: [
'',
[Validators.required, Validators.email],
ValidateEmailNotTaken.createValidator(this.signupService),
{updateOn: 'blur'}
]
});
<form [formGroup]="myForm">
<input type="text" formControlName="name">
<input type="email" formControlName="email">
<!-- Other related errors go here-->
<div *ngIf="myForm.get('email').errors && myForm.get('email').errors.emailUnavailable">
This email is already taken.
</div>
</form>
ngOnInit() {
this.myForm = this.fb.group({
name: ['', Validators.required],
email: [
'',
[Validators.required, Validators.email],
ValidateEmailNotTaken.createValidator(this.signupService)
]
});
}
constructor(private fb: FormBuilder,
private loanAmountValidatorService: LoanAmountValidatorService) { }
ngOnInit() {
this.newsletterForm = this.fb.group({
email: ['', [Validators.required, Validators.email]],
}, {validators: this.loanAmountValidatorService.loanAmountValidator});
}
import { Directive } from '@angular/core';
import { AbstractControl, NG_VALIDATORS, ValidationErrors, Validator } from '@angular/forms';
import { LoanAmountValidatorService } from './loan-amount-validator.service';
@Directive({
selector: '[razrooLoanAmount]',
providers: [{ provide: NG_VALIDATORS, useExisting: LoanAmountDirective, multi: true }]
})
export class LoanAmountDirective implements Validator {
constructor(private loanAmountValidatorService: LoanAmountValidatorService) {}
import { Injectable } from '@angular/core';
import { FormGroup, ValidationErrors, ValidatorFn } from '@angular/forms';
@Injectable({
providedIn: 'root'
})
export class LoanAmountValidatorService {
constructor() { }
<mat-form-field [formGroup]="newsletterForm" class="email-field" >
<input matInput razrooNumber formControlName="email" placeholder="Your E-mail" required>
</mat-form-field>
<ng-container *ngIf="email.invalid && (email.dirty || email.touched)">
<mat-error *ngIf="email.errors.number">Not a number</mat-error>
</ng-container>