Created
February 26, 2016 18:45
-
-
Save AFelipeTrujillo/83032297a67347f502b0 to your computer and use it in GitHub Desktop.
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
<div ng-app="app" ng-controller="controller"> | |
<p> | |
Default Value: {{value}} | |
</p> | |
<p> | |
is {{number}} Even Number? {{result}} | |
</p> | |
<p> | |
{{sum}} {{pi}} | |
</p> | |
</div> |
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('app',[]); | |
app.constant('PI',3.1416); | |
app.config(function($provide){ | |
$provide.provider('otherService',function(PI){ | |
this.$get = function(){ | |
var factory = {}; | |
factory.add = function(a,b){ | |
return a + b; | |
} | |
factory.PI = PI; | |
return factory; | |
} | |
}) | |
}); | |
app.value('defaultValue',100); | |
app.factory('mathFactory',function(){ | |
var factory = {}; | |
factory.mod = function(a,b){ | |
return a % b; | |
} | |
return factory; | |
}); | |
app.service('calcService',function(mathFactory){ | |
this.isEven = function(a){ | |
return mathFactory.mod(a,2) === 0; | |
} | |
}); | |
app.controller('controller',function($scope,defaultValue,calcService,otherService){ | |
$scope.value = defaultValue; | |
$scope.number = 14; | |
$scope.result = calcService.isEven($scope.number); | |
$scope.sum = otherService.add(1,2); | |
$scope.pi = otherService.PI | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment