Search docs/

ionic generate

Contents

Automatically create framework features

ionic generate <type> <name> [options]

This command uses the Angular CLI to generate features such as pages, components, directives, services, etc.

  • For a full list of available types, use npx ng g --help
  • For a list of options for a types, use npx ng g <type> --help

You can specify a path to nest your feature within any number of subdirectories. For example, specify a name of "pages/New Page" to generate page files at src/app/pages/new-page/.

To test a generator before file modifications are made, use the --dry-run option.

Examples

ionic generate ionic generate pageionic generate page contactionic generate component contact/formionic generate component login-form --change-detection=OnPushionic generate directive ripple --skip-importionic generate service api/user

Inputs

type

Description

The type of feature (e.g. page, component, directive, service)

name

Description

The name/path of the feature being generated