Skip to content

Instantly share code, notes, and snippets.

@corburn
Created May 4, 2015 03:46
Show Gist options
  • Save corburn/de4c5c05bcfd3a622e69 to your computer and use it in GitHub Desktop.
Save corburn/de4c5c05bcfd3a622e69 to your computer and use it in GitHub Desktop.
import {bootstrap, Component, Decorator, View, If, For, EventEmitter} from 'angular2/angular2';
import {FormBuilder, Validators, FormDirectives, ControlGroup} from 'angular2/forms';
@Component({
selector: 'app',
injectables: [FormBuilder]
})
@View({
template: `
<div [control-group]="form" class="form-group"
[class.has-success="form.controls.name.valid"]
[class.has-error="! form.controls.name.valid"]
>
<input control="name" class="form-control">
{{ form.controls.name.value }}
</div>
`,
directives: [FormBuilder]
})
class AppComponent {
form: ContolGroup;
builder: FormBuilder) {
this.builder = b;
this.form = b.Group({
name: ["", Validators.required]
})
}
}
export function main() {
bootstrap(AppComponent);
}
<!doctype html>
<html>
<title>Survey Builder</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstra,/3.3.4/css/bootstrap" charset="utf-8">
<script src="https://cdn.firebase.com/js/client/2.2.3/firebase.js"</script>
<body>
<app>
Loading...
</app>
$SCRIPTS$
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment