Skip to content

Instantly share code, notes, and snippets.

@mattcanty
Last active August 29, 2015 14:04
Show Gist options
  • Save mattcanty/cec8225bfc6c9bf21b98 to your computer and use it in GitHub Desktop.
Save mattcanty/cec8225bfc6c9bf21b98 to your computer and use it in GitHub Desktop.
Template including controller and service
var app = angular.module('some-basic-app',
[
'services'
]
);
<!DOCTYPE html>
<html ng-app="some-basic-app">
<head>
<title>Basic AngularJS Architecture</title>
</head>
<body ng-controller="MainController">
<div>
{{serviceMessage}}
</div>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.js"></script>
<script src="app.js"></script>
<script src="services.js"></script>
<script src="main-controller.js"></script>
</body>
</html>
function MainController($scope, someService){
$scope.serviceMessage = someService.message();
}
var services = angular.module('services', []);
services.factory('someService', function(http){
var someService = {};
someService.message = function(){
return "Hello World!";
}
return someService;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment