angularjs - How to use service in angular.js controller? -


i have created service not getting how use service in controller.

(function(){     'use.strict';      angular      .module('app.core')      .factory('sharebtwnctrlr', sharebtwnctrlrservice);      /** @nginject */     function sharebtwnctrlrservice() {         sharebtwnctrlr = function($scope, $rootscope){             $scope.value = $rootscope.test;         }         return sharebtwnctrlr;     } })(); 

in above code $rootscope.test coming 1 controller , have use $scope.value in controller using service. controller below

(function (){     'use strict';      angular.module('app.product')         .controller('productcontroller', productcontroller);      /** @nginject */     //productcontroller.$inject = ['$http', '$location', '$scope'];     function productcontroller($http, $location, $rootscope, $scope, $localstorage, $interval, $timeout,$mddialog, $document, sharebtwnctrlr){         var vm = this;        } })(); 

you got 2 modules, dependency injector can't inject service app.core app.product. try create new module

var app = angular.module('app', ['app.core','app.product']);  

and

angular.module('app').factory('sharebtwnctrlr', sharebtwnctrlrservice);