<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy AngularJS Tutorial</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
    </head>
    <body>
        <div ng-app="myApp" ng-controller="serviceCtrl">
            <h3> Multiplication of two number using Custom Service in AngularJS</h3>
            <p>Multiply value of 10 and 50 is <b>{{mul}}</b> </p>
        </div>
        <script>
            var app = angular.module('myApp', []);
            app.service('multiply', function() {
                this.myFunc = function (a,b) {
                    return a*b;
                }
            });
            app.controller('serviceCtrl', function($scope, multiply) {
                $scope.mul = multiply.myFunc(10,50);
            });
        
</script>
    </body>
</html>
 


www.wikitechy.com © Copyright 2016. All Rights Reserved.