我是Angular 2中的新成员。我只是在角2中创建了一个基本组件。组件正在工作,但是当我在HTML中多次调用该组件时,它仅适用于第一次调用。如何在Angular 2中多次调用组件
下面是app.component.ts
import {Component} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser'
@Component({
selector: 'click-me',
template: `<input #box (keyup.enter)="values=box.value"
(blur)="onKey(box.value)" />`
})
export class AppComponent {
clickMessage = '';
onKey(value: string) {
}
onClickMe() {
this.clickMessage = 'You are my hero!';
}
bootstrap(AppComponent);
当我在我的主要的index.html多次使用'<click-me></click-me>'
,它适用于第一个。
下面是index.html的
<html>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/app.component')
.then(null, console.error.bind(console));
</script>
</head>
<!-- 3. Display the application -->
<body>
<click-me></click-me>
<click-me></click-me>
</body>
</html>
我如何更新到lattest版本。它现在在测试版吗? – sarath
更新了npm更新 – muetzerich
。但仍然有问题。 :-( – sarath