ng-state
  • Introduction
  • Main differences
  • Getting Started
    • Instalation
    • Examples
  • Core concepts
    • Main idea
      • More complex flow visualization
    • Configuration
      • Immer Setup
      • ImmutableJs Setup
    • Store
      • Operators
      • Optimistic updates plugin
      • Optimistic updates plugin
      • Form manager plugin
        • onChange hook
        • shouldUpdateState hook
        • Custom form elements
      • Persist state plugin
        • Configuring custom storage
    • Actions
      • Immer
      • ImmutaleJs
      • Injectable Actions
    • Components with Actions
      • Signal Actions
      • State Actions
    • @InjectStore decorator
    • @WithStore decorator
    • @ComponentState decorator
    • Dispatcher
  • Different scenarios
    • Passing list item index via router
    • ngOnChanges hook
    • FormManager pitfalls
  • Unit testing
    • Setup
    • Test store
    • Test actions
    • Test component with actions
    • Test with Angular TestBed
  • Debugging
    • Setup
    • Redux DevTools
    • Automated changes output
    • Manual state changes check
    • Additional debugging information
  • Production
    • Production mode
    • Server Side Rendering (SSR)
  • Other information
    • Best practices
    • CLI
      • Custom Configurations
    • Performance
    • Blog Posts
    • Contributing
Powered by GitBook
On this page

Was this helpful?

  1. Other information

CLI

PreviousBest practicesNextCustom Configurations

Last updated 6 years ago

Was this helpful?

ng-state has optional package ng-state-cli which makes developers lives easier by generating new files or integrating state management to existing ones.

Install it from npm

npm install ng-state-cli -g

In terminal type ngstate and answer couple questions:

  1. Name of the component - e.g: todos

  2. Choose directory

  3. Enter state path like you do in @InjectStore decorator - e.g: ['todos', '${stateIndex}'] or 'todos'

  4. Chose Add or Append

When Add is chosen ng-state-cli will generate these files

  • actions

  • component

  • html template

  • styles

  • spec

When Append is chosen ng-state-cli will do following

  • generate action

  • modify component file

  • modify spec file

Append plays nice with angular cli