Could someone help me with a challenge I am facing while using Typescript? I am attempting to assign the return value from an async service call to a local variable like this:
private searchResult;
public search():void{
this.DashboardService.dashboardSearch(this.searchParams)
.then(
function (result:ISearchResult) {
// promise was fullfilled
console.log(result);
this.searchResult = result;
},
function (error) {
// handle errors here
console.log(error);
}
);
};
<div id="dashboard-content" ng-controller="dashboardCtrl as vm">
<h3>{{vm.searchResult}}</h3>
</div>
Although the dashboardSearch service is returning an object with data, I seem to be struggling with assigning that data to my local variable.
Below is the error message along with the data displayed in the Google Chrome console.log
https://i.sstatic.net/PNI01.png
I would appreciate guidance on how to successfully bind the data from my service to my local class variable.