0

我遇到了一个与 Angular CLI 相关的奇怪问题,它似乎无法正确创建组件,原因未知。当我编写“ng generate component modal”或者我使用 IntelliJ Angular CLI 工具时,结果是 component.ts 文件的渲染错误。

请看这里:

import {Component, OnInit

< %
if (!!viewEncapsulation) { %>,
  ViewEncapsulation < %
}
%>
< %
if (changeDetection !== 'Default') { %>,
  ChangeDetectionStrategy < %
}
%>
}
from
'@angular/core';

@Component({
  selector: 'app-form-modal', < % if
(inlineTemplate)
{ %>
  template: `
    <p>
      form-modal works!
    </p>
  `, < %
}
else
{ %>
  templateUrl: './form-modal.component.html', < %
}
if (inlineStyle) { %>
  styles: [] < %
} else { %>
  styleUrls: ['./form-modal.component.css'] < %
}
%>
< %
if (!!viewEncapsulation) { %>,
  encapsulation: ViewEncapsulation. < %= viewEncapsulation % > < %
}
if (changeDetection !== 'Default') { %>,
  changeDetection: ChangeDetectionStrategy. < %= changeDetection % > < %
}
%>
})
export class
< %= classify(name) % > Component
implements
OnInit
{

  constructor()
  {
  }

  ngOnInit()
  {
  }

}

你能解释一下这是什么怪事吗?先感谢您。

编辑:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 6.0.8
Node: 8.10.0
OS: linux x64
Angular: 6.0.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.8.3

根据要求,我还添加了ng --v.

考虑到该项目已作为 webapp 子文件夹导入到更大的 Java 应用程序中。我可以使用ng serve --open.

4

0 回答 0