Typescript : AngularJS retrieving a result object -


i have angularjs service in typescript makes https call returns data. results child object of response.data follows response.data.result.

how access it? cannot response.data.result compile time error response.data defined under ihttppromisecallbackarg<t> not have result property.

 class applicationservice implements iapplicationservice {         private webapiurl;         static $inject = ['$http'];          constructor(private $http: ng.ihttpservice) {             this.webapiurl = 'http://localhost';             this.$http = $http;         }          getapplications(): ng.ipromise<iapplication[]> {             return this.$http.get(this.webapiurl + '/api/applications')                 .then((response: ng.ihttppromisecallbackarg<iapplication[]>): iapplication[]=> {                 return <iapplication[]>response.data;             });         }     } 

after this.$http.get(this.webapiurl + '/api/applications'), try changing ng.ihttppromisecallbackarg<iapplication[]> { data: { result: iapplication[] } } type.

class applicationservice implements iapplicationservice {     private webapiurl;     static $inject = ['$http'];      constructor(private $http: ng.ihttpservice) {         this.webapiurl = 'http://localhost';         this.$http = $http;     }      getapplications(): ng.ipromise<iapplication[]> {         return this.$http.get(this.webapiurl + '/api/applications')         .then((response: { data: { result: iapplication[] } }): iapplication[]=> {             return response.data.result;         });     } } 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -