Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

When I use the following code, it works as expected:

$scope.firebase.car1.seats = index+1;

However, when I need for the car to be a variable, I'm not sure how to do this. I am correctly passing 'thecar' variable, but I'm not sure how to separate the code to make angularjs/javascript see that what I am supplying is a variable.

  buttonClicked: function(index) {
    firebase.$loaded().then(function() {

      alert(thecar);
      //this works

      $scope.firebase.thecar.seats = index+1;
      //this doesn't work, "cannot set property 'seats' of undefined".

    });
  }
share|improve this question
2  
$scope.firebase[thecar].seats –  Blackhole 21 hours ago
2  
Thank you very much for the help! Guessing I'm being voted down because it's a poorly formed question, categorized incorrectly or something everyone knows. Any way - thank you for helping me! –  jdgower 21 hours ago
1  
Downvote likely due to this being a very basic javascript thing. Apparently someone thought voting you down without telling you why would magically improve the community. Anyway, gave you a vote up for good measure. –  Shawn Erquhart 19 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.