错误AngularJs:未知的提供者

时间:2015-11-11 16:45:12

标签: angularjs

嘿,我是angularJs的新手,我正在为我的应用程序使用服务提供程序,但我收到此错误:未知提供程序:MathServiceProvider< - MathService< - Monservice

这是我的代码:

 <div ng-controller="myController">
 Enter a number:
    <input type="number" ng-model="num" />
    <button ng-click="doSquare()">X<sup>2</sup></button>
    <button ng-click="doCube()">X<sup>3</sup></button>

    Answer: {{answer}}
 </div>

我的Js文件是

  var app=angular.module('myapp',[]);
  app.service('Mathservice',function()
        {
 this.add=function(a,b)
{
return a+b;
}
this.multiplication=function(a,b)
{
return a*b;
}
 this.devise=function(a,b)
{
return a/c;
}
this.Soustraction=function(a,b)
{
return a-c;
}
}
       );
app.service('Monservice', function(MathService){

this.s = function(a) { return Mathservice.multiplication(a,a); };
this.c = function(a) {
return Mathservice.multiplication(a,Mathservice.multiplication(a,a)); };

});

app.controller('myController', function($scope, Monservice) {

$scope.doSquare = function() {
    $scope.answer = Monservice.s($scope.num);
}

$scope.doCube = function() {
    $scope.answer = Monservice.c($scope.num);
}
});

感谢您的帮助

0 个答案:

没有答案