“ ng generate component hero -it”中angular的“ -it”标志是什么意思?

时间:2019-04-04 10:47:39

标签: angular

在学习角度时,我在角度站点上找到了此命令。我冲浪了很多,但没找到任何东西。

2 个答案:

答案 0 :(得分:3)

如果运行命令ng generate component hero,它将生成如下4个文件

heroes.component.css heroes.component.html heroes.component.spec.ts heroes.component.ts

但是,如果您不想生成模板文件(HTML),则可以使用 ng generate component hero -it

答案 1 :(得分:2)

您可以通过ng g c --help查看所有选项注释 在这种情况下,它将为您的组件使用-t inline-template (-t)

@Component({
  selector: 'app-hero',
  template: `
    <p>
      hero works!
    </p>
  `,
  styleUrls: ['./hero.component.css']
})
export class HeroComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

这里是ng-帮助结果:

ng g c --help
Generates and/or modifies files based on a schematic.
usage: ng generate c <name> [options]

arguments:
  schematic
    The schematic or collection:schematic to generate.

options:
  --defaults
    When true, disables interactive input prompts for options with a default.
  --dry-run (-d)
    When true, run through and report activity without writing out results.
  --force (-f)
    When true, force overwriting of existing files.
  --help
    Shows a help message for this command in the console.
  --interactive
    When false, disables interactive input prompts.

Help for schematic c

arguments:
  name
    The name of the component.

options:
  --change-detection (-c)
    Specifies the change detection strategy.
  --entry-component
    Specifies if the component is an entry component of declaring module.
  --export
    Specifies if declaring module exports the component.
  --flat
    Flag to indicate if a directory is created.
  --inline-style (-s)
    Specifies if the style will be in the ts file.
  --inline-template (-t)
    Specifies if the template will be in the ts file.
  --lint-fix
    Specifies whether to apply lint fixes after generating the component.
  --module (-m)
    Allows specification of the declaring module.
  --prefix (-p)
    The prefix to apply to generated selectors.
  --project
    The name of the project.
  --selector
    The selector to use for the component.
  --skip-import
    Flag to skip the module import.
  --spec
    Specifies if a spec file is generated.
  --styleext
    The file extension to be used for style files.
  --view-encapsulation (-v)
    Specifies the view encapsulation strategy.