AngularJS square, cube using provider [on hold]

Problem:

Write an angular application that takes a number as an input from the HTML page and calculates its square root or cube root using Provider. You may want to use .config and .run blocks for coding as needed.

Using the angular service created in the earlier exercise for computing a square root and cube root of a number, modify the code to use Provider in place Factory.

Steps:

You can follow the steps accordingly:

  1. Create Calculator and CalculatorProvider.
  2. Add a controller CalculatorController and use both services Calculator and
  3. CalculatorProvider in it to calculate Square root and Cube root
  4. CalculatorController : Square function and Cube function
  5. Use Default value as 0.

Errors:

  1. Type Error: Calculator Provider.square is not a function

  2. Type Error: Calculator Provider.cube is not a function

  3. Expected undefined to be defined.

Please ignore spaces in the below code

Code:

var app = angular.module('my App', []);
app.config(function($provide) {
   $provide.provider('Calculator', function() {
      this.$get = function() {
         var factory = {};  

         factory.multiply = function(a, b) {
            return a * b; 
         }
         return factory;
      };
   });
});
app.config(function($provide) {
    $provide.provider('Calculator Provider', function(){
        this.$get = function(Calculator) {
            var factory 1 = {}; 
            square = function(a) {
                return Calculator.multiply(a,a);
            };
            cube = function(a) {
                return Calculator.multiply(a, Calculator.multiply(a,a)); 
            }
            return factory 1;
        };

    });

});
app.controller('Calculator Controller', function($scope, Calculator Provider) {
    $scope.answer = 0;
    $scope.Square = function() {
        $scope.answer = Calculator Provider.square($scope.number);
    }

    $scope.Cube = function() {
        $scope.answer = Calculator Provider.cube($scope.number);
    }
});

Source: New feed
Source Url AngularJS square, cube using provider [on hold]