aluckdog
//defineamodulevarmainApp=angular.module("mainApp",[]);//createaservicewhichdefinesamethodsquaretoreturnsquareofanumber.mainApp.service('CalcService',function(MathService){this.square=function(a){returnMathService.multiply(a,a);}});//injecttheservice"CalcService"intothecontrollermainApp.controller('CalcController',function($scope,CalcService,defaultInput){$scope.number=defaultInput;$scope.result=CalcService.square($scope.number);$scope.square=function(){$scope.result=CalcService.square($scope.number);}});就是这样调用service的