-
-
Save adamweeks/a8c315fca93f1f72246c to your computer and use it in GitHub Desktop.
Revealing Module Pattern for Angular Services
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
angular.module('blogpost.service',[]) | |
.service('BlogpostService',BlogpostService); | |
function BlogpostSerivce(){ | |
var service = this; | |
service.getBlogs = getBlogs; | |
service.createBlog = createBlog; | |
service.getBlogName = getBlogName; | |
////////// | |
var blogName = 'Test Blog'; | |
var blogs = ['blog1', 'blog 2', 'blog3']; | |
function getBlogs(){ | |
return blogs | |
} | |
function createBlog(blogObject){ | |
blogs.push(blogObject); | |
} | |
function getBlogName(){ | |
return blogName; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment