Angular 未捕获错误:模板分析错误:通过@prop=";分配动画触发器;exp";带有表达式的属性无效。
我使用的是Angular 5,cli 1.65 post.component.html中的这一行导致以下错误 谷歌控制台:Angular 未捕获错误:模板分析错误:通过@prop=";分配动画触发器;exp";带有表达式的属性无效。,angular,Angular,我使用的是Angular 5,cli 1.65 post.component.html中的这一行导致以下错误 谷歌控制台: Uncaught Error: Template parse errors: Assigning animation triggers via @prop="exp" attributes with an expression is invalid. Use property bindings (e.g. [@prop]="exp") or use an attribut
Uncaught Error: Template parse errors:
Assigning animation triggers via @prop="exp" attributes with an expression is invalid. Use property bindings (e.g. [@prop]="exp") or use an attribute without a value (e.g. @prop) instead. ("<ul class="list-group">
<li [ERROR ->]@ngFor="let post of posts" class="list-group-item"> {{ post.title }}</li>
任何帮助或提示都将不胜感激 将其更改为:
<li *ngFor="let post of posts" class="list-group-item"> {{ post.title }}</li>
{{post.title}
.谢谢!!!我用了“@”。相反,我应该使用“*”。谢谢你告诉我我的错误是什么
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
@Component({
selector: 'app-posts',
templateUrl: './posts.component.html',
styleUrls: ['./posts.component.css']
})
export class PostsComponent implements OnInit {
posts: any[];
constructor(http: Http) {
http.get('http://jsonplaceholder.typicode.com/posts')
.subscribe(response => {
console.log(response.json());
this.posts = response.json();
}
)
}
ngOnInit() {
}
}
<li *ngFor="let post of posts" class="list-group-item"> {{ post.title }}</li>