zoukankan      html  css  js  c++  java
  • angular11报错Can't bind to 'ngForOf' since it isn't a known property of 'tr'. 三种排查办法以及解决方案

    当你遇到Can't bind to 'ngForOf' since it isn't a known property of 'tr'. (" //无法绑定到“ngforof”,因为它不是“tr”的已知属性。(“

    可能问题一:

    当前错误原因是没有绑定ngforof,在@ngmodule()中添加browsermodule到imports:[],如果它是根模块(appmodule),则为commonmodule。

    简而言之,就是根部app.module有没有导入这个基础模块,检查一下

    可能问题二:出现此问题是你的导入有误,修改BrowserModule在控制器的位置

    
    
    import {BrowserModule, CommonModule} from '@angular/common';
    ..
    ..
    @NgModule({
      imports: [BrowserModule, /* or CommonModule */],
      ..
    })
    
    

    可能问题三: 检查一下你的页面是否在当前自己所属模块执行了以下操作

    举例:当前模块名字叫做 aa-management

    aa-management模块下,当前页面名字叫做report

    首先检查这个aa-management.module.ts代码

    
    import { NgModule, Type } from '@angular/core';
    import { SharedModule } from '@shared';
    import { ManagementRoutingModule } from './hr-management-routing.module';  // 看看有没有这样一行代码-------1
    
    import { HrReportComponent } from './hr-report/hr-report.component'
    const COMPONENTS: Type<void>[] = [
      HrReportComponent
    ];
    
    @NgModule({
      imports: [
        SharedModule,
        ManagementRoutingModule  // 看看有没有这样一行代码-------2
      ],
      declarations: COMPONENTS,
    })
    export class ManagementModule { }
    
    

    然后检查一下:hr-management-routing.module.ts

    import { NgModule } from '@angular/core';
    import { RouterModule, Routes } from '@angular/router';
    import { ReportComponent } from './hr-report/hr-report.component'  // 看看有没有这样一行代码-------3
    
    const routes: Routes = [
      { path: 'report', component: ReportComponent },  // 看看有没有这样一行代码-------4
    ];
    
    @NgModule({
      imports: [RouterModule.forChild(routes)],
      exports: [RouterModule]
    })
    export class ManagementRoutingModule { }
    
    

    如果以上都没问题,就OK

  • 相关阅读:
    js 获取浏览器版本号
    怎样写具体设计文档
    android PreferenceScreen使用笔记
    支持向量机通俗导论(理解SVM的三层境地)
    算法导论 第6章 堆排序(简单选择排序、堆排序)
    人脸识别算法初次了解
    循环队列
    ubuntu 下操作文件夹,出现Permission denied的解决的方法
    JFreeChart的使用
    隐藏Activity标题栏
  • 原文地址:https://www.cnblogs.com/sugartang/p/14689694.html
Copyright © 2011-2022 走看看