I have converted my first angular factory to TypeScript in my project. I'm now trying to bring in the constants from a new typescript file.
Here is the typescript file that will eventually hold more than one constant value
module app.config {
export class Constants {
static get Default(): any {
return {
apiServer: 'http://localhost/MyApplication'
}
}
}
angular
.module('app');
}
Here is the new TypeScript file where I'm trying to pull in the value of apiServer that used to be in a constants.config.js file
module app.services {
interface IStoreFactory {
apiServer: string;
}
var constant = new app.config.Constants.Default();
export class StoreFactory implements IStoreFactory {
static $inject = ['$http', '$log']
constructor(private $http, $log) {
}
apiServer = constant.apiServer;
getRegisters() {
return this.$http.get(this.apiServer + 'stores/1/registers');
}
}
angular
.module('app.services')
.service('storeFactory', StoreFactory);
}
When I hard coded the value of apiServer in this service it worked fine. I'm getting the error that it:
cannot read property of 'Constants' of undefined.
What do I need to do to the app.config file to make it accessible in the app.services file?
Side note: Also it seems odd that there is a blank controller I'm sure that isn't being used correctly.