Created
October 13, 2017 15:11
-
-
Save gmittica/b5290caa26d0825cb73365f0be801192 to your computer and use it in GitHub Desktop.
Lesson // source http://jsbin.com/valamahuzo
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script> | |
<script src="https://code.jquery.com/jquery.min.js"></script> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> | |
<title>Lesson</title> | |
</head> | |
<body ng-app="myApp"> | |
<div class="container" ng-controller="myCtrl"> | |
<div class="well"> | |
<h1>Services</h1> | |
</div> | |
</div> | |
<script id="jsbin-javascript"> | |
angular.module("myApp", []) | |
.controller("myCtrl", ['$scope', 'myService', 'myOtherService', function($scope, myService, myOtherService) { | |
//myService.testMethod(); | |
console.log(myOtherService.testMethod(5)); | |
}]) | |
.factory("myService", [function() { | |
return { | |
testMethod: function() { | |
console.log("i'm a service"); | |
} | |
}; | |
}]) | |
.service("myOtherService", ['myService', function(myService) { | |
var service = {}; | |
service.testMethod = function(number) { | |
myService.testMethod(); | |
return service.otherMethod(number) * 2; | |
}; | |
service.otherMethod = function(number) { | |
return number * 5; | |
} | |
return service; | |
}]) | |
; | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular.module("myApp", []) | |
.controller("myCtrl", ['$scope', 'myService', 'myOtherService', function($scope, myService, myOtherService) { | |
//myService.testMethod(); | |
console.log(myOtherService.testMethod(5)); | |
}]) | |
.factory("myService", [function() { | |
return { | |
testMethod: function() { | |
console.log("i'm a service"); | |
} | |
}; | |
}]) | |
.service("myOtherService", ['myService', function(myService) { | |
var service = {}; | |
service.testMethod = function(number) { | |
myService.testMethod(); | |
return service.otherMethod(number) * 2; | |
}; | |
service.otherMethod = function(number) { | |
return number * 5; | |
} | |
return service; | |
}]) | |
;</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
angular.module("myApp", []) | |
.controller("myCtrl", ['$scope', 'myService', 'myOtherService', function($scope, myService, myOtherService) { | |
//myService.testMethod(); | |
console.log(myOtherService.testMethod(5)); | |
}]) | |
.factory("myService", [function() { | |
return { | |
testMethod: function() { | |
console.log("i'm a service"); | |
} | |
}; | |
}]) | |
.service("myOtherService", ['myService', function(myService) { | |
var service = {}; | |
service.testMethod = function(number) { | |
myService.testMethod(); | |
return service.otherMethod(number) * 2; | |
}; | |
service.otherMethod = function(number) { | |
return number * 5; | |
} | |
return service; | |
}]) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment