Skip to content

Instantly share code, notes, and snippets.

@Mattnmoore
Mattnmoore / app.component.ts
Last active October 22, 2018 17:19
Angular Router Titles
constructor(private router: Router,
private route: ActivatedRoute
private titleService: Title) {
router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => {
let title = this.getTitleFromRoute(route.root) + ' - Dinolytics';
this.titleService.setTitle(title);
});
}
@Mattnmoore
Mattnmoore / websites.component.html
Created October 22, 2018 17:15
Angular Component Focus
<ng-select #websiteSelect
[items]="selectWebsites$ | async"
formControlName="website"
placeholder="Select a website"
bindLabel="name"
labelForId="website">
</ng-select>
@Mattnmoore
Mattnmoore / app.component.ts
Created October 22, 2018 17:13
Angular route change focus
constructor(private router: Router) {
router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(() => {
document.getElementsByTagName('h1')[0].focus();
});
}
@Mattnmoore
Mattnmoore / external-emails.component.ts
Created October 22, 2018 17:10
Angular dynamic field focus management
public deleteEmail(index) {
// remove email field
// set focus
document.getElementById('emails-' + (index - 1)).focus();
}
public removeAllExternalEmails() {
@Mattnmoore
Mattnmoore / external-emails.component.html
Last active October 22, 2018 17:08
Angular Focus Directive
<input focus-input formControlName="address" id="emails-{{ ii }}" class="form-control" type="email" name="emails[]" />
@Mattnmoore
Mattnmoore / websites.component.html
Created October 22, 2018 17:05
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>
@Mattnmoore
Mattnmoore / app.component.html
Last active August 31, 2023 07:04
Angular Skip Link
<div id="skip-link">
<a [href]="skipLinkPath">Skip to content</a>
</div>
<main id="main-content" class="content">
<!--Main content goes here-->
</main>
@Mattnmoore
Mattnmoore / app.component.html
Created October 22, 2018 16:56
Broken Angular skip link
<a [routerLink]="['./']" fragment="main-content">Skip to content</a>
"dependencies": {
"bower": {
"gulp": "^3.8.8",
"gulp-angular-templatecache": "^1.4.2",
"gulp-concat": "^2.4.1",
"gulp-ng-annotate": "^0.3.3",
"gulp-uglify": "^1.0.1",
"gulp-watch": "^1.1.0",
"yargs": "^1.3.2",
"gulp-if": "^1.2.5",
@Mattnmoore
Mattnmoore / sandbox.php
Created November 5, 2014 06:25
Some base repository setup
<?php
interface BaseRepository {
public function find($id);
}
class BaseRepository implements BaseRepository {
private $model;