Skip to content

Instantly share code, notes, and snippets.

@palcisto
Last active April 15, 2016 17:53
Show Gist options
  • Save palcisto/ef8826dad5074a7dbd12 to your computer and use it in GitHub Desktop.
Save palcisto/ef8826dad5074a7dbd12 to your computer and use it in GitHub Desktop.
Angular Factory Boilerplate
(function() {
'use strict';
angular
.module('', [])
.factory('serviceName', serviceName);
serviceName.$inject = [];
function serviceName() {
let factory = {
square: square
};
function square(n) {
return n * n;
}
return factory;
}
})();
@vjwilson
Copy link

Could you include a stub of a function to return, so that people could just replace it with their first function?

(Also, I don't think we usually need argument as a param for the Factory constructor function.)

Example:

  function factoryName() {
    let factory = {
      square: square
    }

    function square(n) {
      return n * n;
    }

    return factory;
  }


@palcisto
Copy link
Author

@vjwilson good I'll make these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment