0

I have this var room_price and I need to use that variable in jQuery. Is there any way to do that.

 $http({
            method:'GET',
            url: ''
        }).then(function(response){
            var roomdata = response.data;
            $scope.roomdata = roomdata;
            var roomtype = roomdata.data;
            angular.forEach(roomtype, function(value, key){
                var id = value.room_type_id;
                var room_image_id = value.image;
                var room_price = value.rack_price;
                $scope.room_image_id = room_image_id;
                $scope.id = id;
            });

jQuery code

$(function() {
  var p;
});

I need to set the value in p.

DragonBorn
  • 1,809
  • 5
  • 20
  • 44
  • How are these pieces of code related to one another? If they're entirely separate then you may need to set the value on the `window` object or perhaps store it in local storage or a cookie or something of that nature. – David Mar 20 '17 at 12:54
  • 2
    The question is: Why do you need to use this `var` in `jQuery`? Isn't `AngularJS` enough? – Castro Roy Mar 20 '17 at 13:12

1 Answers1

1

The simplest way of doing this is use of global variable, make room_price as a global variable and use it wherever you want just keep it in mind after the usage don't forget to clean it. so at the top of your js file take var room_price=null ;