Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
AngularFire2可以';t绑定到';ngForAs';因为它不是';t'的已知属性;李';_Angular_Typescript_Firebase_Angularfire2_Ngfor - Fatal编程技术网

AngularFire2可以';t绑定到';ngForAs';因为它不是';t'的已知属性;李';

AngularFire2可以';t绑定到';ngForAs';因为它不是';t'的已知属性;李';,angular,typescript,firebase,angularfire2,ngfor,Angular,Typescript,Firebase,Angularfire2,Ngfor,我正在尝试使用*ngFor循环从firebase数据库循环出一个简单的字符串列表。但是,我在控制台中收到一条错误消息: Unhandled Promise rejection: Template parse errors: Can't bind to 'ngForAs' since it isn't a known property of 'li'. (" <ul> <li [ERROR ->]*ngFor="let item as items | async"

我正在尝试使用*ngFor循环从firebase数据库循环出一个简单的字符串列表。但是,我在控制台中收到一条错误消息:

Unhandled Promise rejection: Template parse errors:
Can't bind to 'ngForAs' since it isn't a known property of 'li'. ("  <ul>
    <li [ERROR ->]*ngFor="let item as items | async">
        {{item.$value}}
    </li>
"): AppComponent@1:7
Property binding ngForAs not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("  <ul>
    [ERROR ->]<li *ngFor="let item as items | async">
        {{item.$value}}
    </li>
"): AppComponent@1:3 ; Zone: <root> ; Task: Promise.then ; Value: SyntaxError {__zone_symbol__error: Error: Template parse errors:
Can't bind to 'ngForAs' since it isn't a known property of 'li'. ("  <…, _nativeError: ZoneAwareError, __zone_symbol__currentTask: ZoneTask, __zone_symbol__stack: "Error: Template parse errors:↵Can't bind to 'ngFor…ttp://localhost:4200/polyfills.bundle.js:6423:35)", __zone_symbol__message: "Template parse errors:↵Can't bind to 'ngForAs' sin…         {{item.$value}}↵    </li>↵"): AppComponent@1:3"} Error: Template parse errors:
Can't bind to 'ngForAs' since it isn't a known property of 'li'. ("  <ul>
    <li [ERROR ->]*ngFor="let item as items | async">
        {{item.$value}}
    </li>
"): AppComponent@1:7
Property binding ngForAs not used by any directive on an embedded template. Make sure that the property name is spelled correctly and all directives are listed in the "@NgModule.declarations". ("  <ul>
    [ERROR ->]<li *ngFor="let item as items | async">
        {{item.$value}}
    </li>
"): AppComponent@1:3
    at SyntaxError.ZoneAwareError (http://localhost:4200/polyfills.bundle.js:6869:33)
    at SyntaxError.BaseError [as constructor] (http://localhost:4200/vendor.bundle.js:64389:16)
    at new SyntaxError (http://localhost:4200/vendor.bundle.js:5723:16)
    at TemplateParser.parse (http://localhost:4200/vendor.bundle.js:17589:19)
    at JitCompiler._compileTemplate (http://localhost:4200/vendor.bundle.js:47585:68)
    at http://localhost:4200/vendor.bundle.js:47468:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (http://localhost:4200/vendor.bundle.js:47468:19)
    at createResult (http://localhost:4200/vendor.bundle.js:47350:19)
    at ZoneDelegate.invoke (http://localhost:4200/polyfills.bundle.js:6211:26)
    at Zone.run (http://localhost:4200/polyfills.bundle.js:6003:43)
    at http://localhost:4200/polyfills.bundle.js:6590:57
    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.bundle.js:6244:31)
    at Zone.runTask (http://localhost:4200/polyfills.bundle.js:6043:47)
    at drainMicroTaskQueue (http://localhost:4200/polyfills.bundle.js:6423:35)
未处理的承诺拒绝:模板分析错误:
无法绑定到'ngForAs',因为它不是'li'的已知属性。(“
    ]*ngFor=“让项目作为项目|异步”> {{item.$value}} "): AppComponent@1:7 嵌入模板上的任何指令都不使用属性绑定。确保属性名称拼写正确,并且所有指令都列在“@NgModule.declarations”中。(“
      [错误->] {{item.$value}} "): AppComponent@1:3 ; 区域:;任务:承诺;值:SyntaxError{{uuuuuu区域\符号\错误:错误:模板分析错误: 无法绑定到'ngForAs',因为它不是'li'的已知属性。(“ {{item.$value}} "): AppComponent@1:7 嵌入模板上的任何指令都不使用属性绑定NGFORA。请确保属性名称拼写正确,并且所有指令都列在“@NgModule.declarations”中(“
        [错误->] {{item.$value}} "): AppComponent@1:3 在SyntaxError.ZoneAwareError(http://localhost:4200/polyfills.bundle.js:6869:33) 在SyntaxError.BaseError[作为构造函数](http://localhost:4200/vendor.bundle.js:64389:16) 在新SyntaxError(http://localhost:4200/vendor.bundle.js:5723:16) 在TemplateParser.parse(http://localhost:4200/vendor.bundle.js:17589:19) 在JIT编译器上。\u compiletTemplate(http://localhost:4200/vendor.bundle.js:47585:68) 在http://localhost:4200/vendor.bundle.js:47468:62 at Set.forEach(本机) 在JIT编译器上。\u compileComponents(http://localhost:4200/vendor.bundle.js:47468:19) 在createResult(http://localhost:4200/vendor.bundle.js:47350:19) 在ZoneDelegate.invoke(http://localhost:4200/polyfills.bundle.js:6211:26) 在Zone.run(http://localhost:4200/polyfills.bundle.js:6003:43) 在http://localhost:4200/polyfills.bundle.js:6590:57 在ZoneDelegate.invokeTask(http://localhost:4200/polyfills.bundle.js:6244:31) 在Zone.runTask(http://localhost:4200/polyfills.bundle.js:6043:47) 在drainMicroTaskQueue(http://localhost:4200/polyfills.bundle.js:6423:35)
下面是我用来循环的代码

<ul>
    <li *ngFor="let item as items | async">
        {{item.$value}}
    </li>
  </ul>
    {{item.$value}}
以下是组件代码:

import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AngularFire, FirebaseListObservable } from 'angularfire2';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})

export class AppComponent {
  title = 'app works!';

  items: FirebaseListObservable<any[]>;

  constructor(private af: AngularFire){
    this.items = af.database.list('/items');
  }
}
从'@angular/core'导入{Component};
从“@angular/common”导入{CommonModule};
从“angularfire2”导入{AngularFire,FirebaseListObservable};
@组成部分({
选择器:'应用程序根',
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent{
title='appworks!';
项目:可观察到的FirebaseList;
建造师(私人af:AngularFire){
this.items=af.database.list('/items');
}
}
我以前在其他项目上使用过ngFor循环加载,但我不明白为什么它不起作用,请帮助我:)

谢谢您


<li *ngFor="let item as items | async">
应该是

<li *ngFor="let item of items | async">
                     ^^

^^

应该是

<li *ngFor="let item of items | async">
                     ^^

^^