mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 20:39:17 +08:00
[restangular] extendModel and extendCollection belongs to IProvider (#25257)
* [restangular] extendModel and extendCollection belongs to IProvider * fix(restangular): function returns the object
This commit is contained in:
4
types/restangular/index.d.ts
vendored
4
types/restangular/index.d.ts
vendored
@@ -69,6 +69,8 @@ declare namespace restangular {
|
||||
setSelfLinkAbsoluteUrl(value: boolean): IProvider;
|
||||
setParentless(value: any): IProvider;
|
||||
setPlainByDefault(isPlain: boolean): IProvider;
|
||||
extendModel(route: string, extender: (model: IElement) => any): IProvider;
|
||||
extendCollection(route: string, extender: (collection: ICollection) => any): IProvider;
|
||||
}
|
||||
|
||||
interface ICustom {
|
||||
@@ -94,8 +96,6 @@ declare namespace restangular {
|
||||
restangularizeCollection(parent: any, element: any, route: string): ICollection;
|
||||
service(route: string, parent?: any): IScopedService;
|
||||
stripRestangular(element: any): any;
|
||||
extendModel(route: string, extender: (model: IElement) => any): void;
|
||||
extendCollection(route: string, extender: (collection: ICollection) => any): void;
|
||||
}
|
||||
|
||||
interface IScopedService extends IService {
|
||||
|
||||
@@ -27,6 +27,16 @@ myApp.config((RestangularProvider: restangular.IProvider) => {
|
||||
return elem;
|
||||
});
|
||||
|
||||
RestangularProvider.extendModel('accounts', function(model: any) {
|
||||
model.prettifyAmount = function() {};
|
||||
return model;
|
||||
});
|
||||
|
||||
RestangularProvider.extendCollection('accounts', function(collection: any) {
|
||||
collection.totalAmount = function() {};
|
||||
return collection;
|
||||
});
|
||||
|
||||
RestangularProvider.setRestangularFields({
|
||||
id: "_id",
|
||||
route: "restangularRoute",
|
||||
|
||||
Reference in New Issue
Block a user