JSFiddle - React, Tailwind, and code Playground

by spechackers

HTML

<div ng-app="myApp" ng-controller="TestCtrl">
    {{service.getUserName()}}
    <br />
    {{service.addNewMethod()}}
</div>

JavaScript

var otherModule = angular.module('OtherModule',[]);


otherModule.service("UserService", function(){
    this.getUserName = function(){
        return "Vinoth"
    }
});

var myApp = angular.module("myApp", ["OtherModule"]);

myApp.config(function($provide){
    $provide.decorator("UserService", function($delegate){
        $delegate.getUserName = function(){
            return "Modified Vinoth"
        }
        
        $delegate.addNewMethod = function(){
            return "Added New Method"
        }
        
        return $delegate;
    });
});

myApp.controller("TestCtrl", ["$scope", "UserService", function($scope, UserService){
     $scope.service = UserService;
}]);