For the context, we use c# for the server, angular with typescript for the client and grunt to build the client (instead of visual studio default compilator)
We want to factorize some angular services between two projects in our visual studio solution, using grunt to put all the file together. The current structure is the following:
Project A
- App
- Externals (we copy here all the definitions file and js file from project Common)
- Orders
- orders.index.ts
- Services
- ordersService.ts
- orders.services.index.ts
Project B
- App
- Externals (we copy here all the definitions files and js file from project Common)
- ... (no specific OrderService)
Project Common
- App
- Orders
- orders.index.ts
- Services
- ordersService.ts
- orders.services.index.ts
We define the service OrderService in ordersService.ts inside the project Common, because the methods of this service are used by Project A and project B. But inside Project A, we want additional operations used only by project A, so we want to extend the service inside project A.
For now, the only result is that the project A file is overridden by the one from project Common. So is it possible to extends an angular service and, if yes, how?
Edit:
To be clearer, an example:
module Orders {
export interface IOrdersResourceClass extends ng.resource.IResourceClass<Common.IEmptyResource> {
listAllOrders(success: (orders: Order[]) => void, error?: Function): void;
getOrder(success: (order: order[]) => void, error?: Function): void;
}
angular
.module("prefix.orders.resources")
.factory("ordersRsc",
['$resource', ($resource: ng.resource.IResourceService): IOrdersResourceClass => {
var listAllOrders: ng.resource.IActionDescriptor = {
method: 'GET',
url: Common.RestServicesAddresses.Order + '/years',
isArray: true,
};
OrderService.ts from project Common
module Orders {
export interface IOrdersResourceClass {
changeOrder(success: () => void, error?: Function): void;
}
angular
.module("prefix.orders.resources")
.factory("ordersRsc",
['$resource', ($resource: ng.resource.IResourceService): IOrdersResourceClass => {
var changeOrder: ng.resource.IActionDescriptor = {
method: 'GET',
url: Common.RestServicesAddresses.Order,
isArray: true,
};
OrderService from project A
The idea would be to use everywhere 'ordersRsc', but to extends it only in project A.