I am trying to modify my controller's variables from within a call to $http (which receives data from an API). These controller variables are bound in my view with ng-model.
However, it's not working -- nothing is displaying!
angular
.module('myApp')
.controller('contactController', ['$scope', '$http', ContactController]);
function ContactController($scope, $http) {
this.firstName = '';
this.lastName = '';
$http.get('../server/getdata').success(function(data) {
// I would like to set the firstName and lastName variables
// from the above parent scope into here. Is this possible?
this.firstName = data.firstName;
this.lastName = data.lastName;
});
}
Any thoughts here??