i having issues using $q.defer in typescript controller. error this.$q.defer not function. typescript....
export class accountwizardcontroller implements iaccountwizardscope { account: account; static $inject = ['$q'] constructor(private $q: ng.iqservice) { } savestate(): ng.ipromise<account> { console.log(this.$q); var deferred = this.$q.defer<account>(); console.log(deferred); return deferred.promise; } } export interface iaccountwizardscope { account: contractmonitor.models.account; savestate(): ng.ipromise<account>; } when call savestate() method in view error. has me baffled.
thanks.
$q has had defer since (ref). guess this.$q undefined, , case because have wrong this. fix, use fat arrow preserve context:
savestate = (): ng.ipromise<account> => { console.log(this.$q); var deferred = this.$q.defer<account>(); console.log(deferred); return deferred.promise; }
Comments
Post a Comment