在"@ angular/material"集合中找不到原理图"materialDashboard"

Pan*_*kar 15 angular-material angular

我试图使用以下命令创建仪表板:

ng generate @angular/material:materialDashboard --name myDashboard
Run Code Online (Sandbox Code Playgroud)

当我执行命令时,它导致错误:

Schematic "materialDashboard" not found in collection
"@angular/material". Error: Schematic "materialDashboard" not found in
collection "@angular/material".
  at SchematicEngine.createSchematic (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular-devkit/schematics/src/engine/engine.js:155:23)
  at CollectionImpl.createSchematic (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular-devkit/schematics/src/engine/collection.js:12:29)
  at Object.getSchematic (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/utilities/schematics.js:36:23)
  at GenerateCommand.getOptions (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/models/schematic-command.js:194:40)
  at GenerateCommand.<anonymous> (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:38:53)
  at Generator.next (<anonymous>)
  at /Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:7:71
  at new Promise (<anonymous>)
  at __awaiter (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:3:12)
  at GenerateCommand.initialize (/Users/xyx/Desktop/Git/question-authoring-platform/node_modules/@angular/cli/commands/generate.js:30:16)
Run Code Online (Sandbox Code Playgroud)

即使我尝试了其他命令myTablematNavbar

ng generate @angular/material:materialNavbar --name matNavbar
ng generate @angular/material:materialTable --name myTable
Run Code Online (Sandbox Code Playgroud)

上述两个命令发生了同样的错误.我错过了什么吗?

Pan*_*kar 47

调查结果是命令别名用于产生的materialShell,materialDashboard,materialNavmaterialTable从除去schematics/collection.json@angular/material.而在使用它时,您只能使用它们的烤肉串案例形式.

materialShell => material-shell
materialDashboard => material-dashboard
materialNav => material-nav
materialTable => material-table
Run Code Online (Sandbox Code Playgroud)

在此承诺

所以不要使用像这样的旧命令

ng generate @angular/material:materialNav --name my-navbar
Run Code Online (Sandbox Code Playgroud)

使用

ng generate @angular/material:material-nav --name my-navbar
Run Code Online (Sandbox Code Playgroud)


小智 6

在官方文档中

安装Schematics

ng add @angular/material
Run Code Online (Sandbox Code Playgroud)

发电机原理图

导航示意图

ng generate @angular/material:material-nav --name <component-name>
Run Code Online (Sandbox Code Playgroud)

仪表板原理图

ng generate @angular/material:material-dashboard --name <component-name>
Run Code Online (Sandbox Code Playgroud)

表示意图

ng generate @angular/material:material-table --name <component-name>
Run Code Online (Sandbox Code Playgroud)