Skip to content

Commit

Permalink
fix: show default snippet in select
Browse files Browse the repository at this point in the history
fixes #59
  • Loading branch information
hjalmers committed Sep 26, 2018
1 parent ac8c80d commit 2c0d525
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</button>
</li>
</ul>
<select class="custom-select d-sm-none" [(ngModel)]="activeSnippet">
<select class="custom-select d-sm-none" [compareWith]="compareFn" [(ngModel)]="activeSnippet">
<option *ngFor="let snippet of sources" [ngValue]="snippet">{{snippet.name}}</option>
</select>
<code-snippet [snippet]="activeSnippet" [texts]="texts"></code-snippet>
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export class ExemplifyComponent implements OnChanges {
}
}

/* compare options */
compareFn(o1: Snippet, o2: Snippet): boolean {
return o1 && o2 ? o1.name === o2.name : o1 === o2;
}

/* prepend snippet to list of snippet */
private addSnippet(snippet: Snippet) {
this.sources = [snippet, ...this.sources];
Expand Down

0 comments on commit 2c0d525

Please sign in to comment.