As you develop your app you'll want to add additional components. That's where the sub-generators come in.
Important: While we are particularly proud of this feature, please note that using modules is only useful in large projects. We recommend that you only use them, if you know why you want to use them in your project. In our experience for most projects using one module is just fine.
yo m-ionic:module <moduleName>
- create a new module- choose your template:
sidemenu
,tabs
orblank
- add your module to the
app/app.js
:
'use strict';
angular.module('myProject', [
// your modules
'main',
'<newModuleName>'
]);
- restart your
gulp watch
task - in your browser, depending on the template you chose, navigate to
http://localhost:9000/#
/<module-name-in-kebap-case>
forblank
templates/<module-name-in-kebap-case>/list
forsidemenu
andtabs
templates
- Done! - see your new module in action!
AngularJS Components can be handily generated with the following command:
yo m-ionic:component <componentName>
This generates the following four files:
- a component.js file
- a component.html file
- a component.scss file
- a component.spec.js file
To include your component somewhere in your app, use the following syntax:
<mini
content="'some content via attribute'">
Some <span class="green">transcluded</span> content
</mini>
Note: You should probably restart your gulp watch task.
More details on AngularJS Components can be found here:
- https://docs.angularjs.org/guide/component
- https://toddmotto.com/exploring-the-angular-1-5-component-method/
A handy and fast way to create different angular components, handling all the boilerplate and test file generation for you.
The <moduleName>
is optional and defaults to the main module when left blank
yo m-ionic:constant <constantName> <moduleName>
yo m-ionic:controller <controllerName> <moduleName>
yo m-ionic:directive <directiveName> <moduleName>
yo m-ionic:filter <filterName> <moduleName>
yo m-ionic:pair <pairName> <moduleName> # creates controller & template
yo m-ionic:template <templateName> <moduleName>
yo m-ionic:service <serviceName> <moduleName>
If you have gulp watch
running, gulp will automatically inject your new files into your application and they will be available right away.