Atom Packages Directory

a package directory for a text editor of the 21st Century

Standard Angularjs Snippets by Gabo Esquivel

Install with:
    apm install standard-angularjs-snippets
  

Standard AngularJS Snippets

A set of AngularJS snippets based on John Papa’s style guide in standard code style.

js-standard-style

Installation

apm install standard-angularjs-snippets

ES5 Angular 1.4 Snippets

You can use the following snippets in Angular 1.4 applications.

ngmodule⇥ Module definition

js angular .module('${1:module}', [ '${2:dependencies}' ]);

ngcontroller⇥ Controller

```js angular .module(‘${1:module}’) .controller(‘${2:Controller}’, ${2:Controller})

${2:Controller}.$inject = [’${3:dependencies}’]

function ${2:Controller} (${3:dependencies}) { var vm = this

activate()

function activate() {

}   } ```
ngfactory⇥ Factory

```js angular .module(‘${1:module}’) .factory(‘${2:factory}’, ${2:factory});

${2:factory}.$inject = [’${3:dependencies}’]

function ${2:factory} (${3:dependencies}) { var service = { ${4:functionName}: ${4:functionName} }

return service

function ${4:functionName}() {

}   } ```
ngdirective⇥ Directive

```js angular .module(‘${1:module}’) .directive(‘${2:directive}’, ${2:directive})

function ${2:directive} () { var directive = { restrict: ‘${3:EA}’, templateUrl: ‘${4:templateUrl}’, scope: { }, link: linkFunc, controller: ${5:Controller}, controllerAs: ‘vm’, bindToController: true }

return directive

function linkFunc (scope, el, attr, ctrl) {

}   }

${5:Controller}.$inject = [’${6:dependencies}’]

function ${5:Controller} (${6:dependencies}) { var vm = this

activate()

function activate() {

}   } ```
ngservice⇥ Service

```js angular .module(‘${1:module}’) .service(‘${2:Service}’, ${2:Service})

${2:Service}.$inject = [’${3:dependencies}’]

function ${2:Service} (${3:dependencies}) { this.${4:functionName} = ${4:functionName}

function ${4:functionName} () {

}   } ```
ngfilter⇥ Filter

```js angular .module(‘${1:module}’) .filter(‘${2:filter}’, ${2:filter})

function ${2:filter} () { return ${2:filter}Filter

function ${2:filter}Filter (${3:params}) {
    return ${3:params}
}   } ```
ngiife⇥ IIFE angular-styleguide#iife

```js ;(function () { ‘use strict’

${0}

})() ```

Contributing

More than happy to accept external contributions to the project in the form of feedback, bug reports and even better pull requests. Please read the contributing guidelines

Related Repositories

License

The MIT License (MIT)

Copyright (c) 2015, Gabo Esquivel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords: javascript, snippets, standardjs, productivity, angularjs, frontend Suggest keywords
Fork me on GitHub