Skip to content

Instantly share code, notes, and snippets.

@quadriq
Created February 9, 2016 10:27
Show Gist options
  • Save quadriq/c81f772fc5f4d7b1d783 to your computer and use it in GitHub Desktop.
Save quadriq/c81f772fc5f4d7b1d783 to your computer and use it in GitHub Desktop.
<form [ngFormModel]="partiesForm" #f="ngForm">
<label>Name</label>
<input type="text" ngControl="name">
<label>Description</label>
<input type="text" ngControl="description">
<label>Location</label>
<input type="text" ngControl="location">
<button>Add</button>
{{f.value}}
</form>
import {Component, View} from 'angular2/core';
import {FormBuilder, Control, ControlGroup, Validators} from 'angular2/common';
import {Parties} from 'collections/parties';
@Component({
selector: 'parties-form'
})
@View({
templateUrl: 'client/parties-form/parties-form.html'
})
export class PartiesForm {
partiesForm: ControlGroup;
constructor() {
var fb = new FormBuilder();
this.partiesForm = fb.group({
name: [''],
description: [''],
location: ['']
});
}
addParty(party) {
if (this.partiesForm.valid) {
Parties.insert({
name: party.name,
description: party.description,
location: party.location
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment