Can anyone help me to pass the variable $scope.imageRepoUrl from controller.js to app.js
controller.js
.controller('deallistCtrl', ['$scope','deals', function($scope, deals) { $scope.title = "test"; $scope.deals = deals.payload; $scope.imageRepoUrl=$scope.$parent.imageRepoUrl; $scope.appWebUrl=$scope.$parent.appWebUrl; }])
app.js
.state('app.deallists', { url: "/deallists", views: { 'menuContent': { templateUrl: "templates/deallists.html", controller: 'deallistCtrl', resolve: { deals: ['$http', function($http){ return $http.get('deal/deals').then(function(response){ return response.data; }) }] } } }, })
It might help you!!
you can call method that invokes broadcast:
$rootScope.$broadcast('SOME_TAG', 'your value');
and the second controller will listen on this tag like:
$scope.$on('SOME_TAG', function(response) {
// ....
})
Since we can't inject $scope into services, there is nothing like a singleton $scope.
But we can inject $rootScope. So if you store value into the Service, you can run $rootScope.$broadcast('SOME_TAG', 'your value');
in the Service body. (See @Charx description about services)
app.service('productService', function($rootScope) {/*....*/}