Last active
April 26, 2016 16:30
-
-
Save matyax/9623cb90c57a6eb4f2e6f99c4747fd6d to your computer and use it in GitHub Desktop.
Angular 1.x boilerplate
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
/** | |
* Module definition | |
* Usage: | |
* <body ng-app="moduleName">... | |
*/ | |
angular.module('moduleName', [ ]) | |
.config(function(...) { | |
//custom config for this module if necessary | |
}); | |
/** | |
* Controller definition | |
* Usage: | |
* <div ng-controller="ControllerName">... | |
*/ | |
angular.module('moduleName') | |
.controller('ControllerName', ['$scope', 'somethingService', 'somethingProvider', | |
function ControllerName($scope, somethingService, somethingProvider) { | |
}]); | |
/** | |
* Provider definition | |
* Usage: | |
* Dependency injection | |
*/ | |
angular.module('moduleName') | |
.provider('somethingProvider', function SomethingProvider () { | |
var config = { | |
}; | |
this.$get = function() { | |
return { | |
getSomething: function () { | |
return config.something; | |
}, | |
getOtherThing: function { | |
return 'Static value'; | |
} | |
}; | |
}; | |
}); | |
/** | |
* Service definition | |
* Usage: | |
* Dependency injection | |
*/ | |
angular.module('tid.coreModule') | |
.factory('somethingService', [ function SomethingServiceFactory() { | |
return { | |
api: api | |
}; | |
function api(...) { | |
//... | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment