Skip to content

Instantly share code, notes, and snippets.

@pzaich
Created April 19, 2015 17:40
Show Gist options
  • Save pzaich/7a28ab4a750a5d9f6b10 to your computer and use it in GitHub Desktop.
Save pzaich/7a28ab4a750a5d9f6b10 to your computer and use it in GitHub Desktop.
service encapsulation
angular.module('example', [])
.service('libraryService', function () {
var books = [];
this.searchBooks = function () {
// return books that match query
}
});
var library = libraryService;
library.books
=> 'undefined'
library.searchBooks('some title')
=> []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment