Following an online course on TypeScript, the code looks like this:
interface IProduct {
productName: string
}
interface IProductResource extends ng.resource.IResource<IProduct> {
}
interface IDataAccessService {
getProductService(): ng.resource.IResourceClass<IProductResource>
}
class DataAccessService implements IDataAccessService {
static $inject = ['$resource'];
constructor(private $resource:ng.resource.IResourceService) {
}
getProductService():ng.resource.IResourceClass<IProductResource> {
return this.$resource("sampleUrl");
}
}
angular.module('app').service('dataAccessService', DataAccessService);
I am using the dataAccessService
in the following code:
var obj : IProductResource = dataAccessService.getProductService().get();
The variable obj
contains all of Angular's REST helper methods such as $save and $delete, but I cannot access the interface obj.productName
. What could be the issue here?