在Angular2 (beta 13)中,我试图显示从数据库中检索到的数据项列表。这部分工作正常。
但是,当我试图在html表中显示这些项(应用程序名称)时,它不起作用。奇怪的是,当它在列表中显示时,它确实工作。
错误消息
EXCEPTION: Template parse errors:
Unexpected character "EOF" ("
</table>
</div>
</div[ERROR ->]"): ApplicationsComponent@13:5applications.html (引起以上错误)
<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]);谢谢你丹。
更新
这是我试图显示的数据(首选为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);
}
}发布于 2016-04-14 21:52:24
在WebEssentials中,浏览器链接或实时更新似乎是一个问题。重建的PC和没有问题(网络要领没有安装和其他设置没有改变)。
发布于 2016-04-02 05:20:36
可能还有其他问题,因为它与<table><tbody>和beta.13一起工作。
工作演示
<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>
最新情况:
http://plnkr.co/edit/XhH1jjnxGfLMX1CuBgHo?p=preview
https://stackoverflow.com/questions/36366018
复制相似问题