#angular
#angular
Вопрос:
Изучая angular, я нашел эту команду на сайте angular. Я много занимался серфингом, но ничего не нашел.
Комментарии:
Ответ №1:
Если вы запустите команду 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. Этот ответ был бы лучше, если бы в нем объяснялось, что
-i
и-t
означают / обозначают и где находятся документы.
Ответ №2:
Вы можете увидеть все опции comment by, 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 g c —help:
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.