Skip to content

Instantly share code, notes, and snippets.

@Mattnmoore
Created October 22, 2018 17:05
Show Gist options
  • Select an option

  • Save Mattnmoore/f7c0f84853adab98e4df2b283be6ae4a to your computer and use it in GitHub Desktop.

Select an option

Save Mattnmoore/f7c0f84853adab98e4df2b283be6ae4a to your computer and use it in GitHub Desktop.
New Content Focus
<div>
<button type="button" (click)="toggleForm()">
<ng-container *ngIf=" ! showForm">Show form</ng-container>
<ng-container *ngIf="showForm">Back</ng-container>
</button>
<ng-container *ngIf=" ! showForm">
<table id="mytable"></table>
</ng-container>
<ng-container *ngIf="showForm">
<form>
<label>Website</label>
<input type="text" id="website" name="website" />
</form>
</ng-container>
</div>
public toggleForm() {
this.showForm = ! this.showForm;
let focus = this.showForm ? 'website' : 'mytable';
setTimeout(() => {
document.getElementById(focus).focus();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment