我无法弄清楚这个简单的双向绑定在Angular 2中工作的原因是什么,它与配置相关,还是?
import User from "../interfaces/user.interface.ts";
import {Component} from "angular2/core";
@Component({
selector: 'application',
template: '<h2>{{name}}</h2><input [(ngModel)]="name" /><input [(ngModel)]="name" />'
})
export class ApplicationComponent {
public name:String = "test";
}
这里我们有主文件:
///<reference path="../node_modules/angular2/typings/browser.d.ts" />
import 'reflect-metadata';
import {bootstrap} from "angular2/platform/browser"
import {ApplicationComponent} from './components/application.component';
bootstrap(ApplicationComponent);
当我开始输入输入字段时,周围的值之间
{}
没有更新?
我不能继续玩Angular 2,如果这个简单的绑定不起作用,我不相信这与配置文件(webpack.config,tsconfig)有关 .
index.html文件以防万一!
<!DOCTYPE html>
<html>
<head>
<title>asd</title>
</head>
<body>
<application></application>
</body>
<script src="/bundle.js"></script>
</html>
Any ideas to why two-way binding is not working, I appreciated :)
1 回答
如果你有一个Plunker或JSFiddle,这可能有助于理解那里的错误 .
我从您的示例中删除以下代码 . 它对我有用 . 这是我的Plunker与Angular2 2.0.0-beta .
和