1

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;   
                })
            }]
        }
      }
    }, 
  }) 

Luke Peterson
  • 8,584
  • 8
  • 45
  • 46
Seetha Raman
  • 145
  • 2
  • 4
  • 15
  • 1
    The file names themselves mean very little. What in app.js needs this value? If the value is provided by the user, the controller could "hang" the value onto `$rootScope`. – New Dev Mar 04 '15 at 06:41
  • This is a phonegap application with ionic framework, i have added `angular.module('sample.controllers', []) .run(function ($rootScope) { $rootScope.appWebUrl= 'http://URL'; //global variable })` in controller.js , this will be accessible in controller methods with the help of scope . `$scope.$parent.appWebUrl` what we need is to get the data in app.js – Seetha Raman Mar 04 '15 at 06:56
  • 1
    *What/where* in `app.js` do you need this URL? Any reason why you can't define it in a `.constant`? – New Dev Mar 04 '15 at 07:09
  • thanks @NewDev am pretty new to angular , your input helps – Seetha Raman Mar 06 '15 at 09:11
  • [Passing data between controllers in Angular JS?](http://stackoverflow.com/a/20181396/456814) –  Oct 09 '15 at 07:19

0 Answers0