Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.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
Angular 4:NGF用于内部html不工作_Angular - Fatal编程技术网

Angular 4:NGF用于内部html不工作

Angular 4:NGF用于内部html不工作,angular,Angular,这在我的product.component.html中 <div class="col-md-6"> <table class="table table-bordered table-responsive"> <thead> <tr> <th class="text-center">Име</th> <th

这在我的product.component.html中

<div class="col-md-6">
    <table class="table table-bordered table-responsive">
        <thead>
            <tr>
                <th class="text-center">Име</th>
                <th class="text-center">Фамилия</th>
                <th class="text-center">Град</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let i as months">
                <td>{{i}}</td>
            </tr>
        </tbody>
    </table>
</div>
导出类ProductComponent{

  months = ["January", "Feburary", "March", "April", "May", 
        "June", "July", "August", "September",
        "October", "November", "December"];
}

这在我的app.module.ts中

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {RouterModule} from'@angular/router';
import { FormsModule } from '@angular/forms';


import { AppComponent } from './app.component';
import { ProductComponent } from './product/product.component';
import { ItemComponent } from './item/item.component';

@NgModule({
  declarations: [
    AppComponent,
    ProductComponent,
    ItemComponent
  ],
  imports: [
    BrowserModule,
      FormsModule,

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

我没有使用ngFor以html格式打印我的月份,因为错误“无法绑定到'ngForAs',因为它不是'tr'的已知属性。”(“

首先,您的导入中缺少
CommonModule
。请将其添加到
AppModule

import { CommonModule } from `@angular/common';

imports: [
  CommonModule, 
  BrowserModule,
  FormsModule,
],
其次,
*ngFor
语法错误。请将其更正为以下内容

 <tr *ngFor="let i of months">

我认为应该是
let i of months
而不是
let i as months
在你的*NGOK这项工作中,但是在我的html中“*ngFor=“let”是红色下划线不是intellisense。我的IDE Netbeans 8,2
 <tr *ngFor="let i of months">