From the course: Learning the Angular CLI
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Generating directives - Angular Tutorial
From the course: Learning the Angular CLI
Generating directives
- Generating directives can also be achieved using simple commands. Let's suppose we need to generate a directive to modify input elements to only accept text input and name this directive, non-numeric. At the terminal, we can simply type in ng generate directive and we will be placing this in the shared module as well, inside a directives folder. In this case, let's explicitly tell the CLI the declaring model. And we can do that by specifying the --module=shared. A directive file was generated along with a spec file. Note also that the app prefix is added to the directive selector and it's also automatically imported to the shared module.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
(Locked)
Creating new code with schematics49s
-
(Locked)
Generating components and modules2m 20s
-
(Locked)
Generating directives56s
-
(Locked)
Generating pipes45s
-
(Locked)
Generating route guards1m 39s
-
(Locked)
Adding libraries using schematics1m 9s
-
(Locked)
Generating custom library1m 27s
-
(Locked)
Challenge: Generating services31s
-
(Locked)
Solution: Generating services42s
-
(Locked)
-
-
-