2

This function fires once at page load, but then never again. I've tried $watch, $apply, and firebase's ref.on('value', ... but no dice. The model changes for the value of scope.job.getApplicants(), but scope.applicants_ is not refreshing when this happens.

function go() {

    var p = [];

    // scope.job.getApplicants() returns a $firebaseArray of user IDs
    scope.job.getApplicants().$loaded().then(function(list) {

      list.forEach(function(app) {

        // User_(app.$id) returns a $firebaseObject
        var user = User_(app.$id);     


        p.push(user);   

      })

    });

    return p;
  }       


  scope.applicants_ = go();
2
  • Is it possible for you to give more code? In plnkr maybe? Commented Jul 2, 2015 at 16:53
  • @geckob got it working, see below Commented Jul 2, 2015 at 16:59

1 Answer 1

2

This is how I resolved the problem:

ref.on('value', function(apps) {
    var applicantIDs = Object.keys(apps.val());       
    scope.applicants_ = applicantIDs.map(function(app) {
      return User_(app);
    });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.