Skip to content

Instantly share code, notes, and snippets.

View ryananthonydrake's full-sized avatar

Ryan Drake ryananthonydrake

View GitHub Profile
@ryananthonydrake
ryananthonydrake / angular-route-example.js
Created September 23, 2015 10:35
An example of Angular routes using ngRoute and $routeProvider
angular.module('NoteApp', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/notes', {
templateUrl: 'templates/pages/notes/index.html'
})
.when('/users', {
templateUrl: 'templates/pages/users/index.html'
})
.when('/notes/new', {
templateUrl: 'templates/pages/notes/edit.html'
angular.module("<ModuleName>").factory("<ServiceName>", function <ServiceName>Factory() {
return { <object containing shared functions> }
});
// The $get function is where you return an object and inject services
// Providers run before everything else, so the only thing you can inject into them is other providers
angular.module("<ModuleName>").provider("<ServiceName>", function <ServiceName>Provider(otherProvider) {
this.$get <factory function>
});