angular.d.ts 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735
  1. // Type definitions for Angular JS 1.4+
  2. // Project: http://angularjs.org
  3. // Definitions by: Diego Vilar <http://github.com/diegovilar>
  4. // Definitions: https://github.com/borisyankov/DefinitelyTyped
  5. /// <reference path="../jquery/jquery.d.ts" />
  6. declare var angular: angular.IAngularStatic;
  7. // Support for painless dependency injection
  8. interface Function {
  9. $inject?: string[];
  10. }
  11. // Collapse angular into ng
  12. import ng = angular;
  13. // Support AMD require
  14. declare module 'angular' {
  15. export = angular;
  16. }
  17. ///////////////////////////////////////////////////////////////////////////////
  18. // ng module (angular.js)
  19. ///////////////////////////////////////////////////////////////////////////////
  20. declare module angular {
  21. // not directly implemented, but ensures that constructed class implements $get
  22. interface IServiceProviderClass {
  23. new (...args: any[]): IServiceProvider;
  24. }
  25. interface IServiceProviderFactory {
  26. (...args: any[]): IServiceProvider;
  27. }
  28. // All service providers extend this interface
  29. interface IServiceProvider {
  30. $get: any;
  31. }
  32. interface IAngularBootstrapConfig {
  33. strictDi?: boolean;
  34. }
  35. ///////////////////////////////////////////////////////////////////////////
  36. // AngularStatic
  37. // see http://docs.angularjs.org/api
  38. ///////////////////////////////////////////////////////////////////////////
  39. interface IAngularStatic {
  40. bind(context: any, fn: Function, ...args: any[]): Function;
  41. /**
  42. * Use this function to manually start up angular application.
  43. *
  44. * @param element DOM element which is the root of angular application.
  45. * @param modules An array of modules to load into the application.
  46. * Each item in the array should be the name of a predefined module or a (DI annotated)
  47. * function that will be invoked by the injector as a run block.
  48. * @param config an object for defining configuration options for the application. The following keys are supported:
  49. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  50. */
  51. bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
  52. /**
  53. * Use this function to manually start up angular application.
  54. *
  55. * @param element DOM element which is the root of angular application.
  56. * @param modules An array of modules to load into the application.
  57. * Each item in the array should be the name of a predefined module or a (DI annotated)
  58. * function that will be invoked by the injector as a run block.
  59. * @param config an object for defining configuration options for the application. The following keys are supported:
  60. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  61. */
  62. bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
  63. /**
  64. * Use this function to manually start up angular application.
  65. *
  66. * @param element DOM element which is the root of angular application.
  67. * @param modules An array of modules to load into the application.
  68. * Each item in the array should be the name of a predefined module or a (DI annotated)
  69. * function that will be invoked by the injector as a run block.
  70. * @param config an object for defining configuration options for the application. The following keys are supported:
  71. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  72. */
  73. bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
  74. /**
  75. * Use this function to manually start up angular application.
  76. *
  77. * @param element DOM element which is the root of angular application.
  78. * @param modules An array of modules to load into the application.
  79. * Each item in the array should be the name of a predefined module or a (DI annotated)
  80. * function that will be invoked by the injector as a run block.
  81. * @param config an object for defining configuration options for the application. The following keys are supported:
  82. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  83. */
  84. bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
  85. /**
  86. * Use this function to manually start up angular application.
  87. *
  88. * @param element DOM element which is the root of angular application.
  89. * @param modules An array of modules to load into the application.
  90. * Each item in the array should be the name of a predefined module or a (DI annotated)
  91. * function that will be invoked by the injector as a run block.
  92. * @param config an object for defining configuration options for the application. The following keys are supported:
  93. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  94. */
  95. bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
  96. /**
  97. * Use this function to manually start up angular application.
  98. *
  99. * @param element DOM element which is the root of angular application.
  100. * @param modules An array of modules to load into the application.
  101. * Each item in the array should be the name of a predefined module or a (DI annotated)
  102. * function that will be invoked by the injector as a run block.
  103. * @param config an object for defining configuration options for the application. The following keys are supported:
  104. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  105. */
  106. bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
  107. /**
  108. * Use this function to manually start up angular application.
  109. *
  110. * @param element DOM element which is the root of angular application.
  111. * @param modules An array of modules to load into the application.
  112. * Each item in the array should be the name of a predefined module or a (DI annotated)
  113. * function that will be invoked by the injector as a run block.
  114. * @param config an object for defining configuration options for the application. The following keys are supported:
  115. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  116. */
  117. bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
  118. /**
  119. * Use this function to manually start up angular application.
  120. *
  121. * @param element DOM element which is the root of angular application.
  122. * @param modules An array of modules to load into the application.
  123. * Each item in the array should be the name of a predefined module or a (DI annotated)
  124. * function that will be invoked by the injector as a run block.
  125. * @param config an object for defining configuration options for the application. The following keys are supported:
  126. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  127. */
  128. bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
  129. /**
  130. * Use this function to manually start up angular application.
  131. *
  132. * @param element DOM element which is the root of angular application.
  133. * @param modules An array of modules to load into the application.
  134. * Each item in the array should be the name of a predefined module or a (DI annotated)
  135. * function that will be invoked by the injector as a run block.
  136. * @param config an object for defining configuration options for the application. The following keys are supported:
  137. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  138. */
  139. bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
  140. /**
  141. * Use this function to manually start up angular application.
  142. *
  143. * @param element DOM element which is the root of angular application.
  144. * @param modules An array of modules to load into the application.
  145. * Each item in the array should be the name of a predefined module or a (DI annotated)
  146. * function that will be invoked by the injector as a run block.
  147. * @param config an object for defining configuration options for the application. The following keys are supported:
  148. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  149. */
  150. bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
  151. /**
  152. * Use this function to manually start up angular application.
  153. *
  154. * @param element DOM element which is the root of angular application.
  155. * @param modules An array of modules to load into the application.
  156. * Each item in the array should be the name of a predefined module or a (DI annotated)
  157. * function that will be invoked by the injector as a run block.
  158. * @param config an object for defining configuration options for the application. The following keys are supported:
  159. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  160. */
  161. bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
  162. /**
  163. * Use this function to manually start up angular application.
  164. *
  165. * @param element DOM element which is the root of angular application.
  166. * @param modules An array of modules to load into the application.
  167. * Each item in the array should be the name of a predefined module or a (DI annotated)
  168. * function that will be invoked by the injector as a run block.
  169. * @param config an object for defining configuration options for the application. The following keys are supported:
  170. * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
  171. */
  172. bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
  173. /**
  174. * Creates a deep copy of source, which should be an object or an array.
  175. *
  176. * - If no destination is supplied, a copy of the object or array is created.
  177. * - If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it.
  178. * - If source is not an object or array (inc. null and undefined), source is returned.
  179. * - If source is identical to 'destination' an exception will be thrown.
  180. *
  181. * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined.
  182. * @param destination Destination into which the source is copied. If provided, must be of the same type as source.
  183. */
  184. copy<T>(source: T, destination?: T): T;
  185. /**
  186. * Wraps a raw DOM element or HTML string as a jQuery element.
  187. *
  188. * If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."
  189. */
  190. element: IAugmentedJQueryStatic;
  191. equals(value1: any, value2: any): boolean;
  192. extend(destination: any, ...sources: any[]): any;
  193. /**
  194. * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
  195. *
  196. * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
  197. *
  198. * @param obj Object to iterate over.
  199. * @param iterator Iterator function.
  200. * @param context Object to become context (this) for the iterator function.
  201. */
  202. forEach<T>(obj: T[], iterator: (value: T, key: number) => any, context?: any): any;
  203. /**
  204. * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
  205. *
  206. * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
  207. *
  208. * @param obj Object to iterate over.
  209. * @param iterator Iterator function.
  210. * @param context Object to become context (this) for the iterator function.
  211. */
  212. forEach<T>(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any;
  213. /**
  214. * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional.
  215. *
  216. * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method.
  217. *
  218. * @param obj Object to iterate over.
  219. * @param iterator Iterator function.
  220. * @param context Object to become context (this) for the iterator function.
  221. */
  222. forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
  223. fromJson(json: string): any;
  224. identity(arg?: any): any;
  225. injector(modules?: any[], strictDi?: boolean): auto.IInjectorService;
  226. isArray(value: any): boolean;
  227. isDate(value: any): boolean;
  228. isDefined(value: any): boolean;
  229. isElement(value: any): boolean;
  230. isFunction(value: any): boolean;
  231. isNumber(value: any): boolean;
  232. isObject(value: any): boolean;
  233. isString(value: any): boolean;
  234. isUndefined(value: any): boolean;
  235. lowercase(str: string): string;
  236. /**
  237. * Deeply extends the destination object dst by copying own enumerable properties from the src object(s) to dst. You can specify multiple src objects. If you want to preserve original objects, you can do so by passing an empty object as the target: var object = angular.merge({}, object1, object2).
  238. *
  239. * Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy.
  240. *
  241. * @param dst Destination object.
  242. * @param src Source object(s).
  243. */
  244. merge(dst: any, ...src: any[]): any;
  245. /**
  246. * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
  247. *
  248. * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved.
  249. *
  250. * @param name The name of the module to create or retrieve.
  251. * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.
  252. * @param configFn Optional configuration function for the module.
  253. */
  254. module(
  255. name: string,
  256. requires?: string[],
  257. configFn?: Function): IModule;
  258. noop(...args: any[]): void;
  259. reloadWithDebugInfo(): void;
  260. toJson(obj: any, pretty?: boolean): string;
  261. uppercase(str: string): string;
  262. version: {
  263. full: string;
  264. major: number;
  265. minor: number;
  266. dot: number;
  267. codeName: string;
  268. };
  269. }
  270. ///////////////////////////////////////////////////////////////////////////
  271. // Module
  272. // see http://docs.angularjs.org/api/angular.Module
  273. ///////////////////////////////////////////////////////////////////////////
  274. interface IModule {
  275. animation(name: string, animationFactory: Function): IModule;
  276. animation(name: string, inlineAnnotatedFunction: any[]): IModule;
  277. animation(object: Object): IModule;
  278. /**
  279. * Use this method to register work which needs to be performed on module loading.
  280. *
  281. * @param configFn Execute this function on module load. Useful for service configuration.
  282. */
  283. config(configFn: Function): IModule;
  284. /**
  285. * Use this method to register work which needs to be performed on module loading.
  286. *
  287. * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration.
  288. */
  289. config(inlineAnnotatedFunction: any[]): IModule;
  290. /**
  291. * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
  292. *
  293. * @param name The name of the constant.
  294. * @param value The constant value.
  295. */
  296. constant(name: string, value: any): IModule;
  297. constant(object: Object): IModule;
  298. /**
  299. * The $controller service is used by Angular to create new controllers.
  300. *
  301. * This provider allows controller registration via the register method.
  302. *
  303. * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
  304. * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
  305. */
  306. controller(name: string, controllerConstructor: Function): IModule;
  307. /**
  308. * The $controller service is used by Angular to create new controllers.
  309. *
  310. * This provider allows controller registration via the register method.
  311. *
  312. * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
  313. * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
  314. */
  315. controller(name: string, inlineAnnotatedConstructor: any[]): IModule;
  316. controller(object: Object): IModule;
  317. /**
  318. * Register a new directive with the compiler.
  319. *
  320. * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
  321. * @param directiveFactory An injectable directive factory function.
  322. */
  323. directive(name: string, directiveFactory: IDirectiveFactory): IModule;
  324. /**
  325. * Register a new directive with the compiler.
  326. *
  327. * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind)
  328. * @param directiveFactory An injectable directive factory function.
  329. */
  330. directive(name: string, inlineAnnotatedFunction: any[]): IModule;
  331. directive(object: Object): IModule;
  332. /**
  333. * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
  334. *
  335. * @param name The name of the instance.
  336. * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
  337. */
  338. factory(name: string, $getFn: Function): IModule;
  339. /**
  340. * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
  341. *
  342. * @param name The name of the instance.
  343. * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
  344. */
  345. factory(name: string, inlineAnnotatedFunction: any[]): IModule;
  346. factory(object: Object): IModule;
  347. filter(name: string, filterFactoryFunction: Function): IModule;
  348. filter(name: string, inlineAnnotatedFunction: any[]): IModule;
  349. filter(object: Object): IModule;
  350. provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule;
  351. provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule;
  352. provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
  353. provider(name: string, providerObject: IServiceProvider): IModule;
  354. provider(object: Object): IModule;
  355. /**
  356. * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
  357. */
  358. run(initializationFunction: Function): IModule;
  359. /**
  360. * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
  361. */
  362. run(inlineAnnotatedFunction: any[]): IModule;
  363. service(name: string, serviceConstructor: Function): IModule;
  364. service(name: string, inlineAnnotatedConstructor: any[]): IModule;
  365. service(object: Object): IModule;
  366. /**
  367. * Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service.
  368. Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator.
  369. *
  370. * @param name The name of the instance.
  371. * @param value The value.
  372. */
  373. value(name: string, value: any): IModule;
  374. value(object: Object): IModule;
  375. /**
  376. * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
  377. * @param name The name of the service to decorate
  378. * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
  379. */
  380. decorator(name:string, decoratorConstructor: Function): IModule;
  381. decorator(name:string, inlineAnnotatedConstructor: any[]): IModule;
  382. // Properties
  383. name: string;
  384. requires: string[];
  385. }
  386. ///////////////////////////////////////////////////////////////////////////
  387. // Attributes
  388. // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
  389. ///////////////////////////////////////////////////////////////////////////
  390. interface IAttributes {
  391. /**
  392. * this is necessary to be able to access the scoped attributes. it's not very elegant
  393. * because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way
  394. * this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656
  395. */
  396. [name: string]: any;
  397. /**
  398. * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with x- or data-) to its normalized, camelCase form.
  399. *
  400. * Also there is special case for Moz prefix starting with upper case letter.
  401. *
  402. * For further information check out the guide on @see https://docs.angularjs.org/guide/directive#matching-directives
  403. */
  404. $normalize(name: string): void;
  405. /**
  406. * Adds the CSS class value specified by the classVal parameter to the
  407. * element. If animations are enabled then an animation will be triggered
  408. * for the class addition.
  409. */
  410. $addClass(classVal: string): void;
  411. /**
  412. * Removes the CSS class value specified by the classVal parameter from the
  413. * element. If animations are enabled then an animation will be triggered for
  414. * the class removal.
  415. */
  416. $removeClass(classVal: string): void;
  417. /**
  418. * Set DOM element attribute value.
  419. */
  420. $set(key: string, value: any): void;
  421. /**
  422. * Observes an interpolated attribute.
  423. * The observer function will be invoked once during the next $digest
  424. * following compilation. The observer is then invoked whenever the
  425. * interpolated value changes.
  426. */
  427. $observe(name: string, fn: (value?: any) => any): Function;
  428. /**
  429. * A map of DOM element attribute names to the normalized name. This is needed
  430. * to do reverse lookup from normalized name back to actual name.
  431. */
  432. $attr: Object;
  433. }
  434. /**
  435. * form.FormController - type in module ng
  436. * see https://docs.angularjs.org/api/ng/type/form.FormController
  437. */
  438. interface IFormController {
  439. /**
  440. * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272
  441. */
  442. [name: string]: any;
  443. $pristine: boolean;
  444. $dirty: boolean;
  445. $valid: boolean;
  446. $invalid: boolean;
  447. $submitted: boolean;
  448. $error: any;
  449. $addControl(control: INgModelController): void;
  450. $removeControl(control: INgModelController): void;
  451. $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController): void;
  452. $setDirty(): void;
  453. $setPristine(): void;
  454. $commitViewValue(): void;
  455. $rollbackViewValue(): void;
  456. $setSubmitted(): void;
  457. $setUntouched(): void;
  458. }
  459. ///////////////////////////////////////////////////////////////////////////
  460. // NgModelController
  461. // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
  462. ///////////////////////////////////////////////////////////////////////////
  463. interface INgModelController {
  464. $render(): void;
  465. $setValidity(validationErrorKey: string, isValid: boolean): void;
  466. // Documentation states viewValue and modelValue to be a string but other
  467. // types do work and it's common to use them.
  468. $setViewValue(value: any, trigger?: string): void;
  469. $setPristine(): void;
  470. $setDirty(): void;
  471. $validate(): void;
  472. $setTouched(): void;
  473. $setUntouched(): void;
  474. $rollbackViewValue(): void;
  475. $commitViewValue(): void;
  476. $isEmpty(value: any): boolean;
  477. $viewValue: any;
  478. $modelValue: any;
  479. $parsers: IModelParser[];
  480. $formatters: IModelFormatter[];
  481. $viewChangeListeners: IModelViewChangeListener[];
  482. $error: any;
  483. $name: string;
  484. $touched: boolean;
  485. $untouched: boolean;
  486. $validators: IModelValidators;
  487. $asyncValidators: IAsyncModelValidators;
  488. $pending: any;
  489. $pristine: boolean;
  490. $dirty: boolean;
  491. $valid: boolean;
  492. $invalid: boolean;
  493. }
  494. interface IModelValidators {
  495. /**
  496. * viewValue is any because it can be an object that is called in the view like $viewValue.name:$viewValue.subName
  497. */
  498. [index: string]: (modelValue: any, viewValue: any) => boolean;
  499. }
  500. interface IAsyncModelValidators {
  501. [index: string]: (modelValue: any, viewValue: any) => IPromise<any>;
  502. }
  503. interface IModelParser {
  504. (value: any): any;
  505. }
  506. interface IModelFormatter {
  507. (value: any): any;
  508. }
  509. interface IModelViewChangeListener {
  510. (): void;
  511. }
  512. /**
  513. * $rootScope - $rootScopeProvider - service in module ng
  514. * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope
  515. */
  516. interface IRootScopeService {
  517. [index: string]: any;
  518. $apply(): any;
  519. $apply(exp: string): any;
  520. $apply(exp: (scope: IScope) => any): any;
  521. $applyAsync(): any;
  522. $applyAsync(exp: string): any;
  523. $applyAsync(exp: (scope: IScope) => any): any;
  524. /**
  525. * Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners.
  526. *
  527. * The event life cycle starts at the scope on which $broadcast was called. All listeners listening for name event on this scope get notified. Afterwards, the event propagates to all direct and indirect scopes of the current scope and calls all registered listeners along the way. The event cannot be canceled.
  528. *
  529. * Any exception emitted from the listeners will be passed onto the $exceptionHandler service.
  530. *
  531. * @param name Event name to broadcast.
  532. * @param args Optional one or more arguments which will be passed onto the event listeners.
  533. */
  534. $broadcast(name: string, ...args: any[]): IAngularEvent;
  535. $destroy(): void;
  536. $digest(): void;
  537. /**
  538. * Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners.
  539. *
  540. * The event life cycle starts at the scope on which $emit was called. All listeners listening for name event on this scope get notified. Afterwards, the event traverses upwards toward the root scope and calls all registered listeners along the way. The event will stop propagating if one of the listeners cancels it.
  541. *
  542. * Any exception emitted from the listeners will be passed onto the $exceptionHandler service.
  543. *
  544. * @param name Event name to emit.
  545. * @param args Optional one or more arguments which will be passed onto the event listeners.
  546. */
  547. $emit(name: string, ...args: any[]): IAngularEvent;
  548. $eval(): any;
  549. $eval(expression: string, locals?: Object): any;
  550. $eval(expression: (scope: IScope) => any, locals?: Object): any;
  551. $evalAsync(): void;
  552. $evalAsync(expression: string): void;
  553. $evalAsync(expression: (scope: IScope) => any): void;
  554. // Defaults to false by the implementation checking strategy
  555. $new(isolate?: boolean, parent?: IScope): IScope;
  556. /**
  557. * Listens on events of a given type. See $emit for discussion of event life cycle.
  558. *
  559. * The event listener function format is: function(event, args...).
  560. *
  561. * @param name Event name to listen on.
  562. * @param listener Function to call when the event is emitted.
  563. */
  564. $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function;
  565. $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function;
  566. $watch<T>(watchExpression: string, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function;
  567. $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function;
  568. $watch<T>(watchExpression: (scope: IScope) => T, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function;
  569. $watchCollection<T>(watchExpression: string, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function;
  570. $watchCollection<T>(watchExpression: (scope: IScope) => T, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function;
  571. $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
  572. $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
  573. $parent: IScope;
  574. $root: IRootScopeService;
  575. $id: number;
  576. // Hidden members
  577. $$isolateBindings: any;
  578. $$phase: any;
  579. }
  580. interface IScope extends IRootScopeService { }
  581. /**
  582. * $scope for ngRepeat directive.
  583. * see https://docs.angularjs.org/api/ng/directive/ngRepeat
  584. */
  585. interface IRepeatScope extends IScope {
  586. /**
  587. * iterator offset of the repeated element (0..length-1).
  588. */
  589. $index: number;
  590. /**
  591. * true if the repeated element is first in the iterator.
  592. */
  593. $first: boolean;
  594. /**
  595. * true if the repeated element is between the first and last in the iterator.
  596. */
  597. $middle: boolean;
  598. /**
  599. * true if the repeated element is last in the iterator.
  600. */
  601. $last: boolean;
  602. /**
  603. * true if the iterator position $index is even (otherwise false).
  604. */
  605. $even: boolean;
  606. /**
  607. * true if the iterator position $index is odd (otherwise false).
  608. */
  609. $odd: boolean;
  610. }
  611. interface IAngularEvent {
  612. /**
  613. * the scope on which the event was $emit-ed or $broadcast-ed.
  614. */
  615. targetScope: IScope;
  616. /**
  617. * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null.
  618. */
  619. currentScope: IScope;
  620. /**
  621. * name of the event.
  622. */
  623. name: string;
  624. /**
  625. * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed).
  626. */
  627. stopPropagation?: Function;
  628. /**
  629. * calling preventDefault sets defaultPrevented flag to true.
  630. */
  631. preventDefault: Function;
  632. /**
  633. * true if preventDefault was called.
  634. */
  635. defaultPrevented: boolean;
  636. }
  637. ///////////////////////////////////////////////////////////////////////////
  638. // WindowService
  639. // see http://docs.angularjs.org/api/ng.$window
  640. ///////////////////////////////////////////////////////////////////////////
  641. interface IWindowService extends Window {
  642. [key: string]: any;
  643. }
  644. ///////////////////////////////////////////////////////////////////////////
  645. // BrowserService
  646. // TODO undocumented, so we need to get it from the source code
  647. ///////////////////////////////////////////////////////////////////////////
  648. interface IBrowserService {
  649. defer: angular.ITimeoutService;
  650. [key: string]: any;
  651. }
  652. ///////////////////////////////////////////////////////////////////////////
  653. // TimeoutService
  654. // see http://docs.angularjs.org/api/ng.$timeout
  655. ///////////////////////////////////////////////////////////////////////////
  656. interface ITimeoutService {
  657. (func: Function, delay?: number, invokeApply?: boolean): IPromise<any>;
  658. cancel(promise: IPromise<any>): boolean;
  659. }
  660. ///////////////////////////////////////////////////////////////////////////
  661. // IntervalService
  662. // see http://docs.angularjs.org/api/ng.$interval
  663. ///////////////////////////////////////////////////////////////////////////
  664. interface IIntervalService {
  665. (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise<any>;
  666. cancel(promise: IPromise<any>): boolean;
  667. }
  668. ///////////////////////////////////////////////////////////////////////////
  669. // AngularProvider
  670. // see http://docs.angularjs.org/api/ng/provider/$animateProvider
  671. ///////////////////////////////////////////////////////////////////////////
  672. interface IAnimateProvider {
  673. /**
  674. * Registers a new injectable animation factory function.
  675. *
  676. * @param name The name of the animation.
  677. * @param factory The factory function that will be executed to return the animation object.
  678. */
  679. register(name: string, factory: () => IAnimateCallbackObject): void;
  680. /**
  681. * Gets and/or sets the CSS class expression that is checked when performing an animation.
  682. *
  683. * @param expression The className expression which will be checked against all animations.
  684. * @returns The current CSS className expression value. If null then there is no expression value.
  685. */
  686. classNameFilter(expression?: RegExp): RegExp;
  687. }
  688. /**
  689. * The animation object which contains callback functions for each event that is expected to be animated.
  690. */
  691. interface IAnimateCallbackObject {
  692. eventFn(element: Node, doneFn: () => void): Function;
  693. }
  694. /**
  695. * $filter - $filterProvider - service in module ng
  696. *
  697. * Filters are used for formatting data displayed to the user.
  698. *
  699. * see https://docs.angularjs.org/api/ng/service/$filter
  700. */
  701. interface IFilterService {
  702. /**
  703. * Usage:
  704. * $filter(name);
  705. *
  706. * @param name Name of the filter function to retrieve
  707. */
  708. (name: string): Function;
  709. }
  710. /**
  711. * $filterProvider - $filter - provider in module ng
  712. *
  713. * Filters are just functions which transform input to an output. However filters need to be Dependency Injected. To achieve this a filter definition consists of a factory function which is annotated with dependencies and is responsible for creating a filter function.
  714. *
  715. * see https://docs.angularjs.org/api/ng/provider/$filterProvider
  716. */
  717. interface IFilterProvider extends IServiceProvider {
  718. /**
  719. * register(name);
  720. *
  721. * @param name Name of the filter function, or an object map of filters where the keys are the filter names and the values are the filter factories. Note: Filter names must be valid angular Expressions identifiers, such as uppercase or orderBy. Names with special characters, such as hyphens and dots, are not allowed. If you wish to namespace your filters, then you can use capitalization (myappSubsectionFilterx) or underscores (myapp_subsection_filterx).
  722. */
  723. register(name: string | {}): IServiceProvider;
  724. }
  725. ///////////////////////////////////////////////////////////////////////////
  726. // LocaleService
  727. // see http://docs.angularjs.org/api/ng.$locale
  728. ///////////////////////////////////////////////////////////////////////////
  729. interface ILocaleService {
  730. id: string;
  731. // These are not documented
  732. // Check angular's i18n files for exemples
  733. NUMBER_FORMATS: ILocaleNumberFormatDescriptor;
  734. DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor;
  735. pluralCat: (num: any) => string;
  736. }
  737. interface ILocaleNumberFormatDescriptor {
  738. DECIMAL_SEP: string;
  739. GROUP_SEP: string;
  740. PATTERNS: ILocaleNumberPatternDescriptor[];
  741. CURRENCY_SYM: string;
  742. }
  743. interface ILocaleNumberPatternDescriptor {
  744. minInt: number;
  745. minFrac: number;
  746. maxFrac: number;
  747. posPre: string;
  748. posSuf: string;
  749. negPre: string;
  750. negSuf: string;
  751. gSize: number;
  752. lgSize: number;
  753. }
  754. interface ILocaleDateTimeFormatDescriptor {
  755. MONTH: string[];
  756. SHORTMONTH: string[];
  757. DAY: string[];
  758. SHORTDAY: string[];
  759. AMPMS: string[];
  760. medium: string;
  761. short: string;
  762. fullDate: string;
  763. longDate: string;
  764. mediumDate: string;
  765. shortDate: string;
  766. mediumTime: string;
  767. shortTime: string;
  768. }
  769. ///////////////////////////////////////////////////////////////////////////
  770. // LogService
  771. // see http://docs.angularjs.org/api/ng.$log
  772. // see http://docs.angularjs.org/api/ng.$logProvider
  773. ///////////////////////////////////////////////////////////////////////////
  774. interface ILogService {
  775. debug: ILogCall;
  776. error: ILogCall;
  777. info: ILogCall;
  778. log: ILogCall;
  779. warn: ILogCall;
  780. }
  781. interface ILogProvider extends IServiceProvider {
  782. debugEnabled(): boolean;
  783. debugEnabled(enabled: boolean): ILogProvider;
  784. }
  785. // We define this as separate interface so we can reopen it later for
  786. // the ngMock module.
  787. interface ILogCall {
  788. (...args: any[]): void;
  789. }
  790. ///////////////////////////////////////////////////////////////////////////
  791. // ParseService
  792. // see http://docs.angularjs.org/api/ng.$parse
  793. // see http://docs.angularjs.org/api/ng.$parseProvider
  794. ///////////////////////////////////////////////////////////////////////////
  795. interface IParseService {
  796. (expression: string): ICompiledExpression;
  797. }
  798. interface IParseProvider {
  799. logPromiseWarnings(): boolean;
  800. logPromiseWarnings(value: boolean): IParseProvider;
  801. unwrapPromises(): boolean;
  802. unwrapPromises(value: boolean): IParseProvider;
  803. }
  804. interface ICompiledExpression {
  805. (context: any, locals?: any): any;
  806. // If value is not provided, undefined is gonna be used since the implementation
  807. // does not check the parameter. Let's force a value for consistency. If consumer
  808. // whants to undefine it, pass the undefined value explicitly.
  809. assign(context: any, value: any): any;
  810. }
  811. /**
  812. * $location - $locationProvider - service in module ng
  813. * see https://docs.angularjs.org/api/ng/service/$location
  814. */
  815. interface ILocationService {
  816. absUrl(): string;
  817. hash(): string;
  818. hash(newHash: string): ILocationService;
  819. host(): string;
  820. /**
  821. * Return path of current url
  822. */
  823. path(): string;
  824. /**
  825. * Change path when called with parameter and return $location.
  826. * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing.
  827. *
  828. * @param path New path
  829. */
  830. path(path: string): ILocationService;
  831. port(): number;
  832. protocol(): string;
  833. replace(): ILocationService;
  834. /**
  835. * Return search part (as object) of current url
  836. */
  837. search(): any;
  838. /**
  839. * Change search part when called with parameter and return $location.
  840. *
  841. * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value.
  842. *
  843. * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url.
  844. */
  845. search(search: any): ILocationService;
  846. /**
  847. * Change search part when called with parameter and return $location.
  848. *
  849. * @param search New search params
  850. * @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign.
  851. */
  852. search(search: string, paramValue: string|number|string[]|boolean): ILocationService;
  853. state(): any;
  854. state(state: any): ILocationService;
  855. url(): string;
  856. url(url: string): ILocationService;
  857. }
  858. interface ILocationProvider extends IServiceProvider {
  859. hashPrefix(): string;
  860. hashPrefix(prefix: string): ILocationProvider;
  861. html5Mode(): boolean;
  862. // Documentation states that parameter is string, but
  863. // implementation tests it as boolean, which makes more sense
  864. // since this is a toggler
  865. html5Mode(active: boolean): ILocationProvider;
  866. html5Mode(mode: { enabled?: boolean; requireBase?: boolean; rewriteLinks?: boolean; }): ILocationProvider;
  867. }
  868. ///////////////////////////////////////////////////////////////////////////
  869. // DocumentService
  870. // see http://docs.angularjs.org/api/ng.$document
  871. ///////////////////////////////////////////////////////////////////////////
  872. interface IDocumentService extends IAugmentedJQuery {}
  873. ///////////////////////////////////////////////////////////////////////////
  874. // ExceptionHandlerService
  875. // see http://docs.angularjs.org/api/ng.$exceptionHandler
  876. ///////////////////////////////////////////////////////////////////////////
  877. interface IExceptionHandlerService {
  878. (exception: Error, cause?: string): void;
  879. }
  880. ///////////////////////////////////////////////////////////////////////////
  881. // RootElementService
  882. // see http://docs.angularjs.org/api/ng.$rootElement
  883. ///////////////////////////////////////////////////////////////////////////
  884. interface IRootElementService extends JQuery {}
  885. interface IQResolveReject<T> {
  886. (): void;
  887. (value: T): void;
  888. }
  889. /**
  890. * $q - service in module ng
  891. * A promise/deferred implementation inspired by Kris Kowal's Q.
  892. * See http://docs.angularjs.org/api/ng/service/$q
  893. */
  894. interface IQService {
  895. new (resolver: (resolve: IQResolveReject<any>) => any): IPromise<any>;
  896. new (resolver: (resolve: IQResolveReject<any>, reject: IQResolveReject<any>) => any): IPromise<any>;
  897. new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
  898. /**
  899. * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
  900. *
  901. * Returns a single promise that will be resolved with an array of values, each value corresponding to the promise at the same index in the promises array. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
  902. *
  903. * @param promises An array of promises.
  904. */
  905. all(promises: IPromise<any>[]): IPromise<any[]>;
  906. /**
  907. * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
  908. *
  909. * Returns a single promise that will be resolved with a hash of values, each value corresponding to the promise at the same key in the promises hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
  910. *
  911. * @param promises A hash of promises.
  912. */
  913. all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any; }>;
  914. /**
  915. * Creates a Deferred object which represents a task which will finish in the future.
  916. */
  917. defer<T>(): IDeferred<T>;
  918. /**
  919. * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it.
  920. *
  921. * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject.
  922. *
  923. * @param reason Constant, message, exception or an object representing the rejection reason.
  924. */
  925. reject(reason?: any): IPromise<any>;
  926. /**
  927. * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
  928. *
  929. * @param value Value or a promise
  930. */
  931. when<T>(value: IPromise<T>|T): IPromise<T>;
  932. /**
  933. * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
  934. *
  935. * @param value Value or a promise
  936. */
  937. when(): IPromise<void>;
  938. }
  939. interface IPromise<T> {
  940. /**
  941. * Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected.
  942. * The successCallBack may return IPromise<void> for when a $q.reject() needs to be returned
  943. * This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
  944. */
  945. then<TResult>(successCallback: (promiseValue: T) => IHttpPromise<TResult>|IPromise<TResult>|TResult|IPromise<void>, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
  946. /**
  947. * Shorthand for promise.then(null, errorCallback)
  948. */
  949. catch<TResult>(onRejected: (reason: any) => IHttpPromise<TResult>|IPromise<TResult>|TResult): IPromise<TResult>;
  950. /**
  951. * Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information.
  952. *
  953. * Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible.
  954. */
  955. finally<TResult>(finallyCallback: () => any): IPromise<TResult>;
  956. }
  957. interface IDeferred<T> {
  958. resolve(value?: T): void;
  959. reject(reason?: any): void;
  960. notify(state?: any): void;
  961. promise: IPromise<T>;
  962. }
  963. ///////////////////////////////////////////////////////////////////////////
  964. // AnchorScrollService
  965. // see http://docs.angularjs.org/api/ng.$anchorScroll
  966. ///////////////////////////////////////////////////////////////////////////
  967. interface IAnchorScrollService {
  968. (): void;
  969. (hash: string): void;
  970. yOffset: any;
  971. }
  972. interface IAnchorScrollProvider extends IServiceProvider {
  973. disableAutoScrolling(): void;
  974. }
  975. /**
  976. * $cacheFactory - service in module ng
  977. *
  978. * Factory that constructs Cache objects and gives access to them.
  979. *
  980. * see https://docs.angularjs.org/api/ng/service/$cacheFactory
  981. */
  982. interface ICacheFactoryService {
  983. /**
  984. * Factory that constructs Cache objects and gives access to them.
  985. *
  986. * @param cacheId Name or id of the newly created cache.
  987. * @param optionsMap Options object that specifies the cache behavior. Properties:
  988. *
  989. * capacity — turns the cache into LRU cache.
  990. */
  991. (cacheId: string, optionsMap?: { capacity?: number; }): ICacheObject;
  992. /**
  993. * Get information about all the caches that have been created.
  994. * @returns key-value map of cacheId to the result of calling cache#info
  995. */
  996. info(): any;
  997. /**
  998. * Get access to a cache object by the cacheId used when it was created.
  999. *
  1000. * @param cacheId Name or id of a cache to access.
  1001. */
  1002. get(cacheId: string): ICacheObject;
  1003. }
  1004. /**
  1005. * $cacheFactory.Cache - type in module ng
  1006. *
  1007. * A cache object used to store and retrieve data, primarily used by $http and the script directive to cache templates and other data.
  1008. *
  1009. * see https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache
  1010. */
  1011. interface ICacheObject {
  1012. /**
  1013. * Retrieve information regarding a particular Cache.
  1014. */
  1015. info(): {
  1016. /**
  1017. * the id of the cache instance
  1018. */
  1019. id: string;
  1020. /**
  1021. * the number of entries kept in the cache instance
  1022. */
  1023. size: number;
  1024. //...: any additional properties from the options object when creating the cache.
  1025. };
  1026. /**
  1027. * Inserts a named entry into the Cache object to be retrieved later, and incrementing the size of the cache if the key was not already present in the cache. If behaving like an LRU cache, it will also remove stale entries from the set.
  1028. *
  1029. * It will not insert undefined values into the cache.
  1030. *
  1031. * @param key the key under which the cached data is stored.
  1032. * @param value the value to store alongside the key. If it is undefined, the key will not be stored.
  1033. */
  1034. put<T>(key: string, value?: T): T;
  1035. /**
  1036. * Retrieves named data stored in the Cache object.
  1037. *
  1038. * @param key the key of the data to be retrieved
  1039. */
  1040. get(key: string): any;
  1041. /**
  1042. * Removes an entry from the Cache object.
  1043. *
  1044. * @param key the key of the entry to be removed
  1045. */
  1046. remove(key: string): void;
  1047. /**
  1048. * Clears the cache object of any entries.
  1049. */
  1050. removeAll(): void;
  1051. /**
  1052. * Destroys the Cache object entirely, removing it from the $cacheFactory set.
  1053. */
  1054. destroy(): void;
  1055. }
  1056. ///////////////////////////////////////////////////////////////////////////
  1057. // CompileService
  1058. // see http://docs.angularjs.org/api/ng.$compile
  1059. // see http://docs.angularjs.org/api/ng.$compileProvider
  1060. ///////////////////////////////////////////////////////////////////////////
  1061. interface ICompileService {
  1062. (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
  1063. (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
  1064. (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction;
  1065. }
  1066. interface ICompileProvider extends IServiceProvider {
  1067. directive(name: string, directiveFactory: Function): ICompileProvider;
  1068. // Undocumented, but it is there...
  1069. directive(directivesMap: any): ICompileProvider;
  1070. aHrefSanitizationWhitelist(): RegExp;
  1071. aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider;
  1072. imgSrcSanitizationWhitelist(): RegExp;
  1073. imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
  1074. debugInfoEnabled(enabled?: boolean): any;
  1075. }
  1076. interface ICloneAttachFunction {
  1077. // Let's hint but not force cloneAttachFn's signature
  1078. (clonedElement?: JQuery, scope?: IScope): any;
  1079. }
  1080. // This corresponds to the "publicLinkFn" returned by $compile.
  1081. interface ITemplateLinkingFunction {
  1082. (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
  1083. }
  1084. // This corresponds to $transclude (and also the transclude function passed to link).
  1085. interface ITranscludeFunction {
  1086. // If the scope is provided, then the cloneAttachFn must be as well.
  1087. (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;
  1088. // If one argument is provided, then it's assumed to be the cloneAttachFn.
  1089. (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
  1090. }
  1091. ///////////////////////////////////////////////////////////////////////////
  1092. // ControllerService
  1093. // see http://docs.angularjs.org/api/ng.$controller
  1094. // see http://docs.angularjs.org/api/ng.$controllerProvider
  1095. ///////////////////////////////////////////////////////////////////////////
  1096. interface IControllerService {
  1097. // Although the documentation doesn't state this, locals are optional
  1098. (controllerConstructor: Function, locals?: any, bindToController?: any): any;
  1099. (controllerName: string, locals?: any, bindToController?: any): any;
  1100. }
  1101. interface IControllerProvider extends IServiceProvider {
  1102. register(name: string, controllerConstructor: Function): void;
  1103. register(name: string, dependencyAnnotatedConstructor: any[]): void;
  1104. allowGlobals(): void;
  1105. }
  1106. /**
  1107. * HttpService
  1108. * see http://docs.angularjs.org/api/ng/service/$http
  1109. */
  1110. interface IHttpService {
  1111. /**
  1112. * Object describing the request to be made and how it should be processed.
  1113. */
  1114. <T>(config: IRequestConfig): IHttpPromise<T>;
  1115. /**
  1116. * Shortcut method to perform GET request.
  1117. *
  1118. * @param url Relative or absolute URL specifying the destination of the request
  1119. * @param config Optional configuration object
  1120. */
  1121. get<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1122. /**
  1123. * Shortcut method to perform DELETE request.
  1124. *
  1125. * @param url Relative or absolute URL specifying the destination of the request
  1126. * @param config Optional configuration object
  1127. */
  1128. delete<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1129. /**
  1130. * Shortcut method to perform HEAD request.
  1131. *
  1132. * @param url Relative or absolute URL specifying the destination of the request
  1133. * @param config Optional configuration object
  1134. */
  1135. head<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1136. /**
  1137. * Shortcut method to perform JSONP request.
  1138. *
  1139. * @param url Relative or absolute URL specifying the destination of the request
  1140. * @param config Optional configuration object
  1141. */
  1142. jsonp<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1143. /**
  1144. * Shortcut method to perform POST request.
  1145. *
  1146. * @param url Relative or absolute URL specifying the destination of the request
  1147. * @param data Request content
  1148. * @param config Optional configuration object
  1149. */
  1150. post<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1151. /**
  1152. * Shortcut method to perform PUT request.
  1153. *
  1154. * @param url Relative or absolute URL specifying the destination of the request
  1155. * @param data Request content
  1156. * @param config Optional configuration object
  1157. */
  1158. put<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1159. /**
  1160. * Shortcut method to perform PATCH request.
  1161. *
  1162. * @param url Relative or absolute URL specifying the destination of the request
  1163. * @param data Request content
  1164. * @param config Optional configuration object
  1165. */
  1166. patch<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>;
  1167. /**
  1168. * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations.
  1169. */
  1170. defaults: IRequestConfig;
  1171. /**
  1172. * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes.
  1173. */
  1174. pendingRequests: any[];
  1175. }
  1176. /**
  1177. * Object describing the request to be made and how it should be processed.
  1178. * see http://docs.angularjs.org/api/ng/service/$http#usage
  1179. */
  1180. interface IRequestShortcutConfig {
  1181. /**
  1182. * {Object.<string|Object>}
  1183. * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified.
  1184. */
  1185. params?: any;
  1186. /**
  1187. * Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent.
  1188. */
  1189. headers?: any;
  1190. /**
  1191. * Name of HTTP header to populate with the XSRF token.
  1192. */
  1193. xsrfHeaderName?: string;
  1194. /**
  1195. * Name of cookie containing the XSRF token.
  1196. */
  1197. xsrfCookieName?: string;
  1198. /**
  1199. * {boolean|Cache}
  1200. * If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching.
  1201. */
  1202. cache?: any;
  1203. /**
  1204. * whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information.
  1205. */
  1206. withCredentials?: boolean;
  1207. /**
  1208. * {string|Object}
  1209. * Data to be sent as the request message data.
  1210. */
  1211. data?: any;
  1212. /**
  1213. * {function(data, headersGetter)|Array.<function(data, headersGetter)>}
  1214. * Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version.
  1215. */
  1216. transformRequest?: any;
  1217. /**
  1218. * {function(data, headersGetter)|Array.<function(data, headersGetter)>}
  1219. * Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version.
  1220. */
  1221. transformResponse?: any;
  1222. /**
  1223. * {number|Promise}
  1224. * Timeout in milliseconds, or promise that should abort the request when resolved.
  1225. */
  1226. timeout?: any;
  1227. /**
  1228. * See requestType.
  1229. */
  1230. responseType?: string;
  1231. }
  1232. /**
  1233. * Object describing the request to be made and how it should be processed.
  1234. * see http://docs.angularjs.org/api/ng/service/$http#usage
  1235. */
  1236. interface IRequestConfig extends IRequestShortcutConfig {
  1237. /**
  1238. * HTTP method (e.g. 'GET', 'POST', etc)
  1239. */
  1240. method: string;
  1241. /**
  1242. * Absolute or relative URL of the resource that is being requested.
  1243. */
  1244. url: string;
  1245. }
  1246. interface IHttpHeadersGetter {
  1247. (): { [name: string]: string; };
  1248. (headerName: string): string;
  1249. }
  1250. interface IHttpPromiseCallback<T> {
  1251. (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void;
  1252. }
  1253. interface IHttpPromiseCallbackArg<T> {
  1254. data?: T;
  1255. status?: number;
  1256. headers?: IHttpHeadersGetter;
  1257. config?: IRequestConfig;
  1258. statusText?: string;
  1259. }
  1260. interface IHttpPromise<T> extends IPromise<IHttpPromiseCallbackArg<T>> {
  1261. success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
  1262. error(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
  1263. then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>|TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
  1264. }
  1265. /**
  1266. * Object that controls the defaults for $http provider
  1267. * https://docs.angularjs.org/api/ng/service/$http#defaults
  1268. */
  1269. interface IHttpProviderDefaults {
  1270. cache?: boolean;
  1271. /**
  1272. * Transform function or an array of such functions. The transform function takes the http request body and
  1273. * headers and returns its transformed (typically serialized) version.
  1274. */
  1275. transformRequest?: ((data: any, headersGetter?: any) => any)|((data: any, headersGetter?: any) => any)[];
  1276. xsrfCookieName?: string;
  1277. xsrfHeaderName?: string;
  1278. withCredentials?: boolean;
  1279. headers?: {
  1280. common?: any;
  1281. post?: any;
  1282. put?: any;
  1283. patch?: any;
  1284. }
  1285. }
  1286. interface IHttpProvider extends IServiceProvider {
  1287. defaults: IHttpProviderDefaults;
  1288. interceptors: any[];
  1289. useApplyAsync(): boolean;
  1290. useApplyAsync(value: boolean): IHttpProvider;
  1291. }
  1292. ///////////////////////////////////////////////////////////////////////////
  1293. // HttpBackendService
  1294. // see http://docs.angularjs.org/api/ng.$httpBackend
  1295. // You should never need to use this service directly.
  1296. ///////////////////////////////////////////////////////////////////////////
  1297. interface IHttpBackendService {
  1298. // XXX Perhaps define callback signature in the future
  1299. (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void;
  1300. }
  1301. ///////////////////////////////////////////////////////////////////////////
  1302. // InterpolateService
  1303. // see http://docs.angularjs.org/api/ng.$interpolate
  1304. // see http://docs.angularjs.org/api/ng.$interpolateProvider
  1305. ///////////////////////////////////////////////////////////////////////////
  1306. interface IInterpolateService {
  1307. (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
  1308. endSymbol(): string;
  1309. startSymbol(): string;
  1310. }
  1311. interface IInterpolationFunction {
  1312. (context: any): string;
  1313. }
  1314. interface IInterpolateProvider extends IServiceProvider {
  1315. startSymbol(): string;
  1316. startSymbol(value: string): IInterpolateProvider;
  1317. endSymbol(): string;
  1318. endSymbol(value: string): IInterpolateProvider;
  1319. }
  1320. ///////////////////////////////////////////////////////////////////////////
  1321. // TemplateCacheService
  1322. // see http://docs.angularjs.org/api/ng.$templateCache
  1323. ///////////////////////////////////////////////////////////////////////////
  1324. interface ITemplateCacheService extends ICacheObject {}
  1325. ///////////////////////////////////////////////////////////////////////////
  1326. // SCEService
  1327. // see http://docs.angularjs.org/api/ng.$sce
  1328. ///////////////////////////////////////////////////////////////////////////
  1329. interface ISCEService {
  1330. getTrusted(type: string, mayBeTrusted: any): any;
  1331. getTrustedCss(value: any): any;
  1332. getTrustedHtml(value: any): any;
  1333. getTrustedJs(value: any): any;
  1334. getTrustedResourceUrl(value: any): any;
  1335. getTrustedUrl(value: any): any;
  1336. parse(type: string, expression: string): (context: any, locals: any) => any;
  1337. parseAsCss(expression: string): (context: any, locals: any) => any;
  1338. parseAsHtml(expression: string): (context: any, locals: any) => any;
  1339. parseAsJs(expression: string): (context: any, locals: any) => any;
  1340. parseAsResourceUrl(expression: string): (context: any, locals: any) => any;
  1341. parseAsUrl(expression: string): (context: any, locals: any) => any;
  1342. trustAs(type: string, value: any): any;
  1343. trustAsHtml(value: any): any;
  1344. trustAsJs(value: any): any;
  1345. trustAsResourceUrl(value: any): any;
  1346. trustAsUrl(value: any): any;
  1347. isEnabled(): boolean;
  1348. }
  1349. ///////////////////////////////////////////////////////////////////////////
  1350. // SCEProvider
  1351. // see http://docs.angularjs.org/api/ng.$sceProvider
  1352. ///////////////////////////////////////////////////////////////////////////
  1353. interface ISCEProvider extends IServiceProvider {
  1354. enabled(value: boolean): void;
  1355. }
  1356. ///////////////////////////////////////////////////////////////////////////
  1357. // SCEDelegateService
  1358. // see http://docs.angularjs.org/api/ng.$sceDelegate
  1359. ///////////////////////////////////////////////////////////////////////////
  1360. interface ISCEDelegateService {
  1361. getTrusted(type: string, mayBeTrusted: any): any;
  1362. trustAs(type: string, value: any): any;
  1363. valueOf(value: any): any;
  1364. }
  1365. ///////////////////////////////////////////////////////////////////////////
  1366. // SCEDelegateProvider
  1367. // see http://docs.angularjs.org/api/ng.$sceDelegateProvider
  1368. ///////////////////////////////////////////////////////////////////////////
  1369. interface ISCEDelegateProvider extends IServiceProvider {
  1370. resourceUrlBlacklist(blacklist: any[]): void;
  1371. resourceUrlWhitelist(whitelist: any[]): void;
  1372. resourceUrlBlacklist(): any[];
  1373. resourceUrlWhitelist(): any[];
  1374. }
  1375. /**
  1376. * $templateRequest service
  1377. * see http://docs.angularjs.org/api/ng/service/$templateRequest
  1378. */
  1379. interface ITemplateRequestService {
  1380. /**
  1381. * Downloads a template using $http and, upon success, stores the
  1382. * contents inside of $templateCache.
  1383. *
  1384. * If the HTTP request fails or the response data of the HTTP request is
  1385. * empty then a $compile error will be thrown (unless
  1386. * {ignoreRequestError} is set to true).
  1387. *
  1388. * @param tpl The template URL.
  1389. * @param ignoreRequestError Whether or not to ignore the exception
  1390. * when the request fails or the template is
  1391. * empty.
  1392. *
  1393. * @return A promise whose value is the template content.
  1394. */
  1395. (tpl: string, ignoreRequestError?: boolean): IPromise<string>;
  1396. /**
  1397. * total amount of pending template requests being downloaded.
  1398. * @type {number}
  1399. */
  1400. totalPendingRequests: number;
  1401. }
  1402. ///////////////////////////////////////////////////////////////////////////
  1403. // Directive
  1404. // see http://docs.angularjs.org/api/ng.$compileProvider#directive
  1405. // and http://docs.angularjs.org/guide/directive
  1406. ///////////////////////////////////////////////////////////////////////////
  1407. interface IDirectiveFactory {
  1408. (...args: any[]): IDirective;
  1409. }
  1410. interface IDirectiveLinkFn {
  1411. (
  1412. scope: IScope,
  1413. instanceElement: IAugmentedJQuery,
  1414. instanceAttributes: IAttributes,
  1415. controller: any,
  1416. transclude: ITranscludeFunction
  1417. ): void;
  1418. }
  1419. interface IDirectivePrePost {
  1420. pre?: IDirectiveLinkFn;
  1421. post?: IDirectiveLinkFn;
  1422. }
  1423. interface IDirectiveCompileFn {
  1424. (
  1425. templateElement: IAugmentedJQuery,
  1426. templateAttributes: IAttributes,
  1427. transclude: ITranscludeFunction
  1428. ): IDirectivePrePost;
  1429. }
  1430. interface IDirective {
  1431. compile?: IDirectiveCompileFn;
  1432. controller?: any;
  1433. controllerAs?: string;
  1434. bindToController?: boolean|Object;
  1435. link?: IDirectiveLinkFn | IDirectivePrePost;
  1436. name?: string;
  1437. priority?: number;
  1438. replace?: boolean;
  1439. require?: any;
  1440. restrict?: string;
  1441. scope?: any;
  1442. template?: any;
  1443. templateUrl?: any;
  1444. terminal?: boolean;
  1445. transclude?: any;
  1446. }
  1447. /**
  1448. * angular.element
  1449. * when calling angular.element, angular returns a jQuery object,
  1450. * augmented with additional methods like e.g. scope.
  1451. * see: http://docs.angularjs.org/api/angular.element
  1452. */
  1453. interface IAugmentedJQueryStatic extends JQueryStatic {
  1454. (selector: string, context?: any): IAugmentedJQuery;
  1455. (element: Element): IAugmentedJQuery;
  1456. (object: {}): IAugmentedJQuery;
  1457. (elementArray: Element[]): IAugmentedJQuery;
  1458. (object: JQuery): IAugmentedJQuery;
  1459. (func: Function): IAugmentedJQuery;
  1460. (array: any[]): IAugmentedJQuery;
  1461. (): IAugmentedJQuery;
  1462. }
  1463. interface IAugmentedJQuery extends JQuery {
  1464. // TODO: events, how to define?
  1465. //$destroy
  1466. find(selector: string): IAugmentedJQuery;
  1467. find(element: any): IAugmentedJQuery;
  1468. find(obj: JQuery): IAugmentedJQuery;
  1469. controller(): any;
  1470. controller(name: string): any;
  1471. injector(): any;
  1472. scope(): IScope;
  1473. isolateScope(): IScope;
  1474. inheritedData(key: string, value: any): JQuery;
  1475. inheritedData(obj: { [key: string]: any; }): JQuery;
  1476. inheritedData(key?: string): any;
  1477. }
  1478. ///////////////////////////////////////////////////////////////////////
  1479. // AnimateService
  1480. // see http://docs.angularjs.org/api/ng.$animate
  1481. ///////////////////////////////////////////////////////////////////////
  1482. interface IAnimateService {
  1483. addClass(element: JQuery, className: string, done?: Function): IPromise<any>;
  1484. enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void;
  1485. leave(element: JQuery, done?: Function): void;
  1486. move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void;
  1487. removeClass(element: JQuery, className: string, done?: Function): void;
  1488. }
  1489. ///////////////////////////////////////////////////////////////////////////
  1490. // AUTO module (angular.js)
  1491. ///////////////////////////////////////////////////////////////////////////
  1492. export module auto {
  1493. ///////////////////////////////////////////////////////////////////////
  1494. // InjectorService
  1495. // see http://docs.angularjs.org/api/AUTO.$injector
  1496. ///////////////////////////////////////////////////////////////////////
  1497. interface IInjectorService {
  1498. annotate(fn: Function): string[];
  1499. annotate(inlineAnnotatedFunction: any[]): string[];
  1500. get(name: string): any;
  1501. has(name: string): boolean;
  1502. instantiate(typeConstructor: Function, locals?: any): any;
  1503. invoke(inlineAnnotatedFunction: any[]): any;
  1504. invoke(func: Function, context?: any, locals?: any): any;
  1505. }
  1506. ///////////////////////////////////////////////////////////////////////
  1507. // ProvideService
  1508. // see http://docs.angularjs.org/api/AUTO.$provide
  1509. ///////////////////////////////////////////////////////////////////////
  1510. interface IProvideService {
  1511. // Documentation says it returns the registered instance, but actual
  1512. // implementation does not return anything.
  1513. // constant(name: string, value: any): any;
  1514. /**
  1515. * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
  1516. *
  1517. * @param name The name of the constant.
  1518. * @param value The constant value.
  1519. */
  1520. constant(name: string, value: any): void;
  1521. /**
  1522. * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
  1523. *
  1524. * @param name The name of the service to decorate.
  1525. * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
  1526. *
  1527. * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
  1528. */
  1529. decorator(name: string, decorator: Function): void;
  1530. /**
  1531. * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
  1532. *
  1533. * @param name The name of the service to decorate.
  1534. * @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
  1535. *
  1536. * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
  1537. */
  1538. decorator(name: string, inlineAnnotatedFunction: any[]): void;
  1539. factory(name: string, serviceFactoryFunction: Function): IServiceProvider;
  1540. factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider;
  1541. provider(name: string, provider: IServiceProvider): IServiceProvider;
  1542. provider(name: string, serviceProviderConstructor: Function): IServiceProvider;
  1543. service(name: string, constructor: Function): IServiceProvider;
  1544. value(name: string, value: any): IServiceProvider;
  1545. }
  1546. }
  1547. }