I want to use angularjs and typescript together. I'm trying to create Orm factory with typescript and stacked with some problem.
I defined my factory class as:
class OrmModel implements IOrmModel { static $inject = ['$http', '$q', 'config']; private name:string; private isNewRecord:boolean = false; constructor(public $http:ng.IHttpService, private $q:ng.IQService, private config:Object) { //... } static findAll(params:ISearchParams, relations:string[]):ng.IPromise<OrmModel> { //... } } Here I defined factory.
OrmModule:ng.IModel = angular.module('core.orm', []); OrmModule.factory('OrmModel', ['$http', '$q', OrmModel]); How can I use $http or $q in findAll() method?
myModule.service('OrmModel', OrmModel).private static $http;, then, in the constructor, do :OrmModel.$http = $http;servicelike thismyModule.service('OrmModel', new OrmModel()), because services in angular most of all are singletons