Q:

Can't save the promise result in a controller

I receive an error while I'm saving my promise in my angular controller:
The controller is:
angular.module('app.controllers')
  .controller('questionController', function($log,QuizCreate,QuestionBank){

    QuestionBank.get().then(function(response){
      this.questions = response.data;
      $log.info(response.data);
    });

    // this.quiz = QuizCreate.generateQuiz();

    $log.info(this.questions);

  }); 

And the error I receive is:
TypeError: Cannot set property 'questions' of undefined

Why???

A:

This failed because the this refers to the anonymous function not to the controller.
angular.module('app.controllers')

.controller('questionController', function($log,QuizCreate,QuestionBank){
       var that=this;
QuestionBank.get().then(function(response){
  that.questions = response.data;
  $log.info(response.data);
});

// this.quiz = QuizCreate.generateQuiz();

$log.info(this.questions);

  }); 

