Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save falendary/d6202d14edd0ad925ac9e064f7bab07f to your computer and use it in GitHub Desktop.
Save falendary/d6202d14edd0ad925ac9e064f7bab07f to your computer and use it in GitHub Desktop.
Transform `<option value="1: '2'"></option>` to <option value="2"></option> in Angular2 <select multiple>
import {Directive, ElementRef} from '@angular/core';
import {Input} from '@angular/core';
@Directive({
selector: '[multipleNormalize]',
})
export class MultipleNormalizeDirective {
@Input('multipleNormalize') model:any;
constructor(private elementRef:ElementRef) {
}
ngOnInit(): void {
this.elementRef.nativeElement.value = this.model;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment