Skip to content

Commit

Permalink
Update demo app.
Browse files Browse the repository at this point in the history
  • Loading branch information
akisvolanis committed May 21, 2017
1 parent d8ff6ea commit dec9a81
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions demo-app/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<h1>Template driven form example</h1>
<simple-ng-tags [(ngModel)]="tags"></simple-ng-tags>
<p>{{tags | json}}</p>
<br><br>
<h1>Reactive form example</h1>
<simple-ng-tags [formControl]="tagsControl"></simple-ng-tags>
<br>
{{tags | json}}
<p>{{tagsControl.value | json}}</p>
6 changes: 3 additions & 3 deletions demo-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { FormControl } from "@angular/forms";
import { FormControl, Validators } from "@angular/forms";

@Component({
selector: 'app-root',
Expand All @@ -8,10 +8,10 @@ import { FormControl } from "@angular/forms";
})
export class AppComponent {
tags: any[] = ['tag 1', 'tag 2', 'tag 3'];
tagsControl = new FormControl();
tagsControl:FormControl;

ngOnInit() {
this.tagsControl.setValue(this.tags);
this.tagsControl = new FormControl(['tag 1', 'tag 2', 'tag 3'], Validators.required);
this.tagsControl.valueChanges.subscribe(tags => {
console.log(tags);
});
Expand Down
5 changes: 5 additions & 0 deletions demo-app/src/app/simple-ng-tags/simple-ng-tags.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
cursor: text;
box-sizing: border-box;
font-family: Sans-Serif;

&.ng-invalid {
background-color: rgba(169, 68, 66, .2);
}
}

* {
Expand Down Expand Up @@ -56,6 +60,7 @@ input {
font-size: 14px;
flex: 1 0 50px;
border: none;
background: transparent;
margin: 2px 6px !important;
}

Expand Down

0 comments on commit dec9a81

Please sign in to comment.