Last active
August 7, 2016 19:51
-
-
Save russellf9/3fb4fbbf0a24ddcbdb58718126370bae to your computer and use it in GitHub Desktop.
A Webstorm Live Template, which generates an Angular 1 Directve with a Controller.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name="ngsd" value="(function () { 'use strict'; /** * * @author $name$ * @date $date$ * * @name * $module$:$directiveName$ * * @param {data} $input1$ An input two-way binding * @param {function} $function1$ An output function * * @description $description$ * Trying to follow the style guidelines from: {https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#angular-docs Angular 1 Style Guide <br> * @example <pre> <$nameDash$ $inputDash1$='data' $functionDash1$='update'> <$nameDash$/> <pre> * */ try { module = angular.module('$module$'); } catch (err) { module = angular.module('$module$', []) } module.directive('$directiveName$', $directiveName$); function $directiveName$Controller($log) { function _callUpdate() { if (typeof $scope.$function1$ == 'function') { $scope.$function1$()(); } else { $log.error('An update function is required!'); } } } function $directiveName$() { return { restrict: 'AE', scope: { $input1$: '=', $function1$: '&' }, templateUrl: '/publc/ $nameSnake$.html', controller: $directiveName$Controller } } }()); $end$" description="An Angular Directive with a Controller function" toReformat="false" toShortenFQNames="true"> | |
<variable name="name" expression="user()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="date" expression="date()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="module" expression="" defaultValue=""module.name"" alwaysStopAt="true" /> | |
<variable name="directiveName" expression="fileNameWithoutExtension()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="input1" expression="" defaultValue=""input"" alwaysStopAt="true" /> | |
<variable name="function1" expression="" defaultValue=""updateFn"" alwaysStopAt="true" /> | |
<variable name="description" expression="" defaultValue=""Add a description of what your Directive does!"" alwaysStopAt="true" /> | |
<variable name="inputDash1" expression="lowercaseAndDash(input1)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="functionDash1" expression="lowercaseAndDash(function1)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="nameSnake" expression="snakeCase(directiveName)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="nameDash" expression="lowercaseAndDash(directiveName)" defaultValue="" alwaysStopAt="true" /> | |
<variable name="end" expression="" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="JAVA_SCRIPT" value="true" /> | |
</context> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment