Skip to content

Instantly share code, notes, and snippets.

@dasibre
Created June 2, 2015 14:29
Show Gist options
  • Select an option

  • Save dasibre/277e537f3e0f3e032987 to your computer and use it in GitHub Desktop.

Select an option

Save dasibre/277e537f3e0f3e032987 to your computer and use it in GitHub Desktop.
Angular Dependency injection]
var myApp = angular.module('myApp', ['myAppController']);
var myAppControllers = angular.module('myAppController', ['myAppServices']);
myAppControllers.controller('HomeCtrl', ['$scope', 'appService', function($scope, appService) {
$scope.name = "James naadjie";
$scope.site = appService
}]);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/danialfarid-angular-file-upload/4.0.2/angular-file-upload.min.js"></script>
<script src="controller.js"></script>
<script src="services.js"></script>
<script src="app.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="HomeCtrl">
{{name}}
{{site}}
</div>
</body>
</html>
var myAppServices = angular.module('myAppServices', []);
myAppServices.factory('appService', function($http) {
return $http.get("http://www.foo.com");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment