在Angular2(beta 13)中,我试图显示从数据库中检索的数据项列表。这部分工作正常。
但是,当我尝试在html表中显示这些项目(应用程序名称)时,它不起作用。奇怪的是,它在列表中显示时确实有效。
错误消息
EXCEPTION: Template parse errors:
Unexpected character "EOF" ("
</table>
</div>
</div[ERROR ->]"): ApplicationsComponent@13:5
applications.html(CAUSES ERROR ABOVE)
<div class="route-container route-container-margin-0 route-container-width-standard">
<div class="route-container-padding-standard">
<p>hello world</p>
<table>
<tbody>
<tr *ngFor="#app of applications">
<td >
{{app.name}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
applications.html(没有错误的工作)
<div class="route-container route-container-margin-0 route-container-width-standard">
<div class="route-container-padding-standard">
<p>hello world</p>
<ul>
<li *ngFor="#app of applications">
{{app.name}}
</li>
</ul>
</div>
</div>
boot.ts
///<reference path="./../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS} from 'angular2/router';
import 'rxjs/Rx'; // kitchen sink
import {AppComponent} from './app.component';
import {HTTP_PROVIDERS} from 'angular2/http';
// Bootstrap the application and reference the required directives
bootstrap(AppComponent, [ROUTER_PROVIDERS, HTTP_PROVIDERS]);
谢谢Dan。
更新
这是我试图显示的数据(首选为app):
[{"applicationID":1,"name":"Applications","description":"Web applications","applicationRef":"Applications","status":true,"icon":"fa fa-th-large","iconColour":"ffffff","applicationColour":"ffffff","routerLink":"Applications","applicationFeatures":null}, .... more here]
这是我的组件(几乎与有效的组件相同)。 有效的组件通过标签包含在页面上,例如,而不起作用的是通过路径遍历提供的。
import {Component, OnInit} from 'angular2/core';
import {ApplicationVM} from '../ViewModels/Application.ViewModel';
import {ApplicationService} from '../Services/application.service';
@Component({
selector: 'ApplicationList',
templateUrl: './app/Applications/Components/applications.html',
providers: [ApplicationService]
})
export class ApplicationsComponent implements OnInit {
constructor(private _applicationService: ApplicationService) { }
errorMessage: string;
applications: ApplicationVM[];
ngOnInit() {
console.log("INIT");
this.getApplications();
}
listApps() {
this.getApplications();
}
getApplications() {
this._applicationService.getApplications()
.subscribe(
apps => this.applications = apps,
error => this.errorMessage = <any>error);
}
}
答案 0 :(得分:2)
可能存在其他一些问题,因为它使用了<table><tbody>
和beta.13
<强> MD5 强>
<div class="route-container route-container-margin-0 route-container-width-standard">
<div class="route-container-padding-standard">
<p>hello world</p>
<table>
<tbody>
<tr *ngFor="#app of users">
<td >
{{app.firstName}}
</td>
</tr>
</tbody>
</table>
</div>
更新:
答案 1 :(得分:0)
WebEssentials中的浏览器链接或实时更新似乎存在问题。重建PC并没有问题(未安装Web Essentials且未更改其他设置)。
完整的GitHub问题帖子: https://github.com/angular/angular/issues/7983