Last active
July 23, 2018 13:39
-
-
Save theotherdy/a51ed7cbbb63c2e288481614b9a288e6 to your computer and use it in GitHub Desktop.
This file contains 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 { isORCIDValidator } from '../../shared/index'; | |
@Component({ | |
selector: 'user-edit-component', | |
templateUrl: './user-edit.component.html', | |
styleUrls: ['./user-edit.component.css'] | |
}) | |
export class UserEditComponent implements OnInit { | |
@Input() user:User; | |
urlRegexPattern: string = 'https:\/\/orcid\.org\/.*'; // Regex pattern to ensure URL starts with https://orcid.org/ | |
// TODO Regex pattern for 16digit part following this | |
/* Creating form */ | |
userForm: FormGroup; | |
// naming form controls as class properties means we can refer to them by name in the html template - see: https://codecraft.tv/courses/angular/forms/model-driven-validation/ | |
... | |
orcid: FormControl; | |
... | |
constructor(private userService: UserService) { | |
} | |
createFormControls() { | |
... | |
this.orcid = new FormControl(this.user.orcid,[Validators.pattern(this.urlRegexPattern),isORCIDValidator]); | |
... | |
} | |
createForm() { | |
this.userForm = new FormGroup({ | |
... | |
orcid: this.orcid, | |
... | |
}); | |
} | |
ngOnInit() { | |
this.createFormControls(); | |
this.createForm(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment