Easy Mat UILive demoDocsGitHubnpm

Docs / Generate an Angular page from the command line

Generate an Angular page from the command line

easy-mat-ui add-page writes an Angular page for you from the components of the library and a data table. It generates the component, the template, the table configuration and the models. It never installs anything.

Run it

npx easy-mat-ui add-page                       # asks what it needs, with a menu by category
npx easy-mat-ui add-page --name stock-items --blocks page-header,stat,table --dry-run --print

Run it at the root of an Angular project. --dry-run shows what would be written and writes nothing.

What it writes

Components you can choose

Models

If your project has a model file that matches the page name (stock-items finds stock-item.model.ts), the command reads its class and reuses it: text, number, boolean and date properties become columns, and the others are left out with a message. Otherwise it generates a generic model with the properties item1, item2 and item3, plus an icon column and an actions column, ready to rename.

Translation keys or plain texts

If @ngx-translate/core is installed, the generated code reads its texts through translation keys and the command adds them to your English file. If you prefer, or if it is not installed, the texts are written in the code and no translation library is needed. Force either choice with --i18n or --no-i18n.

Options

OptionMeaning
--nameName of the page in kebab-case
--dirDestination folder (default src/app/pages)
--blocksComponents, separated by commas: page-header, stat, chip-nav, segmented, language-switch, card-grid, table
--table-modelModel of the table: a name, a path, or generic
--child, --child-modelAdd a second table opened under a row
--i18n, --no-i18nTranslation keys or plain texts
--configRead a complete description of the page from a JSON file
--dry-run, --printShow what would be written, and the files

Prefer a screen

The page builder of the live demo does the same with a preview: choose the components, set them up, copy the code, or download a description that --config reads.

Open the live demo or read the source on GitHub.