I am new to the AngularJS, I need to access the variable which is assigned inside the promise in Javascript

```
this.reqData= this.profileService.getData();
var resp1 = angular.fromJson(this.reqData);
this.data1;

var that = this;
resp1.$promise.then(function (data) {
  that.data1= data.resource.resource;
}).catch(function (error) {
  console.log(error);
});

console.log(this.data1);

```

the variable data1 can be accessed from HTML but it is showing `undefined` in Javascript