Last active
August 29, 2015 14:04
-
-
Save mattcanty/cec8225bfc6c9bf21b98 to your computer and use it in GitHub Desktop.
Running code: http://plnkr.co/edit/P4rhqm
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
Template including controller and service |
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
var app = angular.module('some-basic-app', | |
[ | |
'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
<!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> |
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
function MainController($scope, someService){ | |
$scope.serviceMessage = someService.message(); | |
} |
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
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