Angular CLI无法正确呈现组件元素

时间:2018-07-25 15:08:21

标签: javascript angular typescript components generate

我遇到了一个与Angular CLI相关的怪异问题,似乎无法为未知原因正确创建组件。当我编写“ ng generate component modal”(ng生成组件模态)或使用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的结果。

考虑到该项目已作为较大的Java应用程序中的webapp子文件夹导入。我可以使用ng serve --open正确运行Angular App。

0 个答案:

没有答案