cli-ngcomponent

1.2.8 • Public • Published

CLI-NgComponent

CLI (Command Line Interface) to create component files for angularjs1.5+

Install

  npm install -g cli-ngcomponent

Example

  ngcomponent -c nameComponent
  //creates:
  //nameComponent.module.js
  //nameComponent.controller.js
  //nameComponent.component.js
  //nameComponent.tpl.html

  ngcomponent -c nameComponent --dir
  //creates:
  //nameComponent/nameComponent.module.js
  //nameComponent/nameComponent.controller.js
  //nameComponent/nameComponent.component.js
  //nameComponent/nameComponent.tpl.html

ngcomponent --help

Create files necessary for a component
Usage : ngcomponent [-c|-d|--help]

Options:
  -c, --create  Create files         [default: "test"]
  -d, --dir     Create a directory
  --help        Get help to use CLI

Result

'test.module.js'

(function (angular) {
  'use strict'

  angular
    .module('test', [])

})(window.angular)

'test.controller.js'

(function (angular) {
  'use strict'
  angular
    .module('test')
    .controller('testController', testController)

    testController.$inject = []

    function testController() {
      var vm = this
      vm.$onInit = _onInit

      function _onInit () { }
    }
})(window.angular)

'test.component.js'

(function (angular) {
'use strict'

angular
  .module('test')
  .component('test', {
    templateUrl : './test.tpl.html',
    controller : 'testController',
    controllerAs : '$ctrl',
    bindings : {}
  })

})(window.angular)

'test.tpl.html'

<h1>Component test</h1>

Licence

Licensed under the MIT license.

Package Sidebar

Install

npm i cli-ngcomponent

Weekly Downloads

1

Version

1.2.8

License

MIT

Last publish

Collaborators

  • jmunozr_