Skip to content
Snippets Groups Projects

JetBrains LiveTemplate for AngularJS Decorators

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Jonas Mai

    Quickly extend a given Services method. The file where you use this template needs to be named originalServiceNameDecorator.js

    Edited
    ngdecorator.xml 913 B
    <template name="ngd" value="'use strict';&#10;&#10;export default function $fileName$($delegate, $injector) {&#10; const original$methodToAugmentCap$ = $delegate.$methodToAugment$.bind($delegate);&#10;&#10; $delegate.$methodToAugment$ = function () {&#10; original$methodToAugmentCap$();&#10; $yourAddedFun$&#10; };&#10; return $delegate;&#10;}" description="Decoratorpattern for AngularJS services." toReformat="false" toShortenFQNames="true">
    <variable name="fileName" expression="fileNameWithoutExtension()" defaultValue="" alwaysStopAt="false" />
    <variable name="methodToAugment" expression="" defaultValue="" alwaysStopAt="true" />
    <variable name="methodToAugmentCap" expression="capitalize(methodToAugment)" defaultValue="" alwaysStopAt="false" />
    <variable name="yourAddedFun" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
    <option name="JS_STATEMENT" value="true" />
    </context>
    </template>
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment