I am trying to create a small application using Angular2.0.0-alpha.28 (with corresponding .d.ts) + TypeScript 1.5.0-beta, and I received the following message:
It is not possible to associate with 'controlGroup', since this is not a known property of 'div', and there are no corresponding directives with the corresponding property
index.html
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Angular 2</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,600" />
<script src="https://github.jspm.io/jmcriffey/bower-traceur-runtime@0.0.87/traceur-runtime.js"></script>
<script src="https://jspm.io/system@0.16.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.28/angular2.dev.js"> </script>
</head>
<body>
<radar>Loading...</radar>
<script>System.import('radar-view');</script>
</body>
</html>
radar-view.ts
import {Component, View, bootstrap} from 'angular2/angular2';
import {FormBuilder, Validators, formDirectives, ControlGroup} from 'angular2/angular2';
@Component({
selector: 'radar',
appInjector: [FormBuilder]
})
@View({
template: '<div [control-group]="form"><input control="levels"> {{form.controls.levels.value}}</div>',
directives: [formDirectives]
})
export class RadarView {
form: ControlGroup;
builder: FormBuilder;
constructor(builder: FormBuilder) {
this.builder = builder;
this.form = builder.group({
levels: ["5"]
});
}
}
bootstrap(RadarView);
compilation
tsc --watch --target es5 --module commonjs --emitDecoratorMetadata
Also, when I try to use validators.required, it looks like it was not found:
this.form = builder.group({
levels: ["5", Validators.required]
});
Error: (21, 38) TS2339: the 'required' property does not exist by type 'typeof Validators'.
What is wrong with my code?
source
share