With one call, you took care of a few days worth of work, typing, frustration, and testing. Don’t have a service to hit? Try a slight adjustment on the same command.

$ ng g ng-momentum:crud \

--name=heros \

--obj="{\"id\":\"number\",\"name\":\"string\"}"

Rather than hitting a service you can just specify the proper object to model and have all of your code just the way you want. There are quite a few other surprises and options if you go looking into the documentation (I recommend you do that).

ngMomentum: View

This is going to be semi-controversial, but it is a delineation that has been successful for large projects. Developers often get confused when they start making components in Angular, leaving the components/ folder to become a dumping ground of visual elements. There have been patterns, like atomic design, that tries to differentiate components — only to leave developers trying to decide if a component is an atom, a molecule or an organism. And as time goes on, some components slowly get more complicated and change their scope leading to more confusion in the codebase.

I simplify it. You either have Views or you have Components. Views are specifically a visual component that have a route to them. Components can be any visual component (that aren’t Views). That’s it. One has a route to it, one does not. This makes it a lot easier to describe \and when you go to either the component/ folder or the views/ folder you know what to expect.

Note: Your views/ folder should be the structure of your application, with nested views and paths being your nested folder structure.

With that information set up, ngMomentum handles the creation of Views for you. You’ve already seen this process through the ng-momentum:crud operation.

If you want to create new components, the Angular Schematic already does that for you. If you want to create a View, with Routing, Guards, Unit Tests, basically everything, then you use ngMomentum. Here is an example:

$ ng g ng-momentum:view \

--name=edit-hero --template=form \

--eager=false --skipVo=true --skipService=true \

--vo=hero --voPath=/src/app/vos/hero \

--service=heros --servicePath=/src/app/services/heros

This would create a new “form” view that is lazy loaded with the name “heros” utilizing the Hero VO and HerosService that you created previously.

Empty form view using the existing value object to populate content

You can select from multiple templates, the uiFramework, vo properties and other features. Again, the documentation is the best place to see all the options.

ngMomentum: Service

Services are very simple, this is a way for you to interact with data outside of your application. By default we create an easy way for you to create CRUD operations along with all the unit testing.

ng g ng-momentum:service --name=shoe --operations=crudl

This will create a new service named ShoesService that includes the create , update , list , read , and delete operations along with unit tests within the services/ folder. Like the other sections there are many options and I recommend checking out the documentation for the details.

ngMomentum: Model

This is also a section that you may or may not actually use but can be helpful in the right situation. If you need data in a central location and have multiple components interacting with that data, then a Model is what you’ll want to use. After Injecting a Model into multiple components, it is easy for many areas of your application to always be connected to the point of truth. In ngMomentum, Models come in a variety of formats. ngMomentum builds either a basic Model (with no internal functionality), a list Model (loads a collection of data), or a selected object Model (can create, update, delete, and load a specific data object) for you. Models can also be used to cache your data and have more control. You may not find them helpful at all though. So it is up to you. Here is one example of how to use it.

ng g ng-momentum:model --name=cars --template=list

This will create the CarsModel that can load a list of Car VOs. Along with the Model this will create the service and VO necessary for this to work and all the unit test you’d want. Again, please checkout the documentation.

Use ngMomentum!

We hope you do use ngMomentum and give us some feedback. Right now we are excited to share it as ngMomentum is based on the experience of many years of both Enterprise and Boutique Application Development. We feel if you decide to use it that it will serve you well. As mentioned earlier, please check out the official github location and let us know what you think.

Coming Up With Angular Schematics

If you follow me, you’ll see in the next few stories that we will go further into Schematics than few others have. Learn from the pains I’ve endured and start making something amazing. And if you use ngMomentum in your own projects, let me know. I’d love to get feedback and extend it to be even more useful.