bosun.org@v0.0.0-20210513094433-e25bc3e69a1f/cmd/bosun/web/static/js/angular.d.ts (about) 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 6 7 /// <reference path="jquery.d.ts" /> 8 9 declare var angular: angular.IAngularStatic; 10 11 // Support for painless dependency injection 12 interface Function { 13 $inject?: string[]; 14 } 15 16 // Collapse angular into ng 17 import ng = angular; 18 // Support AMD require 19 declare module 'angular' { 20 export = angular; 21 } 22 23 /////////////////////////////////////////////////////////////////////////////// 24 // ng module (angular.js) 25 /////////////////////////////////////////////////////////////////////////////// 26 declare module angular { 27 28 // not directly implemented, but ensures that constructed class implements $get 29 interface IServiceProviderClass { 30 new (...args: any[]): IServiceProvider; 31 } 32 33 interface IServiceProviderFactory { 34 (...args: any[]): IServiceProvider; 35 } 36 37 // All service providers extend this interface 38 interface IServiceProvider { 39 $get: any; 40 } 41 42 interface IAngularBootstrapConfig { 43 strictDi?: boolean; 44 debugInfoEnabled?: boolean; 45 } 46 47 /////////////////////////////////////////////////////////////////////////// 48 // AngularStatic 49 // see http://docs.angularjs.org/api 50 /////////////////////////////////////////////////////////////////////////// 51 interface IAngularStatic { 52 bind(context: any, fn: Function, ...args: any[]): Function; 53 54 /** 55 * Use this function to manually start up angular application. 56 * 57 * @param element DOM element which is the root of angular application. 58 * @param modules An array of modules to load into the application. 59 * Each item in the array should be the name of a predefined module or a (DI annotated) 60 * function that will be invoked by the injector as a config block. 61 * @param config an object for defining configuration options for the application. The following keys are supported: 62 * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. 63 */ 64 bootstrap(element: string|Element|JQuery|Document, modules?: (string|Function|any[])[], config?: IAngularBootstrapConfig): auto.IInjectorService; 65 66 /** 67 * Creates a deep copy of source, which should be an object or an array. 68 * 69 * - If no destination is supplied, a copy of the object or array is created. 70 * - 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. 71 * - If source is not an object or array (inc. null and undefined), source is returned. 72 * - If source is identical to 'destination' an exception will be thrown. 73 * 74 * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined. 75 * @param destination Destination into which the source is copied. If provided, must be of the same type as source. 76 */ 77 copy<T>(source: T, destination?: T): T; 78 79 /** 80 * Wraps a raw DOM element or HTML string as a jQuery element. 81 * 82 * 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." 83 */ 84 element: IAugmentedJQueryStatic; 85 equals(value1: any, value2: any): boolean; 86 extend(destination: any, ...sources: any[]): any; 87 88 /** 89 * 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. 90 * 91 * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. 92 * 93 * @param obj Object to iterate over. 94 * @param iterator Iterator function. 95 * @param context Object to become context (this) for the iterator function. 96 */ 97 forEach<T>(obj: T[], iterator: (value: T, key: number) => any, context?: any): any; 98 /** 99 * 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. 100 * 101 * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. 102 * 103 * @param obj Object to iterate over. 104 * @param iterator Iterator function. 105 * @param context Object to become context (this) for the iterator function. 106 */ 107 forEach<T>(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any; 108 /** 109 * 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. 110 * 111 * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. 112 * 113 * @param obj Object to iterate over. 114 * @param iterator Iterator function. 115 * @param context Object to become context (this) for the iterator function. 116 */ 117 forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; 118 119 fromJson(json: string): any; 120 identity<T>(arg?: T): T; 121 injector(modules?: any[], strictDi?: boolean): auto.IInjectorService; 122 isArray(value: any): boolean; 123 isDate(value: any): boolean; 124 isDefined(value: any): boolean; 125 isElement(value: any): boolean; 126 isFunction(value: any): boolean; 127 isNumber(value: any): boolean; 128 isObject(value: any): boolean; 129 isString(value: any): boolean; 130 isUndefined(value: any): boolean; 131 lowercase(str: string): string; 132 133 /** 134 * 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). 135 * 136 * Unlike extend(), merge() recursively descends into object properties of source objects, performing a deep copy. 137 * 138 * @param dst Destination object. 139 * @param src Source object(s). 140 */ 141 merge(dst: any, ...src: any[]): any; 142 143 /** 144 * 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. 145 * 146 * 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. 147 * 148 * @param name The name of the module to create or retrieve. 149 * @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. 150 * @param configFn Optional configuration function for the module. 151 */ 152 module( 153 name: string, 154 requires?: string[], 155 configFn?: Function): IModule; 156 157 noop(...args: any[]): void; 158 reloadWithDebugInfo(): void; 159 toJson(obj: any, pretty?: boolean): string; 160 uppercase(str: string): string; 161 version: { 162 full: string; 163 major: number; 164 minor: number; 165 dot: number; 166 codeName: string; 167 }; 168 169 /** 170 * If window.name contains prefix NG_DEFER_BOOTSTRAP! when angular.bootstrap is called, the bootstrap process will be paused until angular.resumeBootstrap() is called. 171 * @param extraModules An optional array of modules that should be added to the original list of modules that the app was about to be bootstrapped with. 172 */ 173 resumeBootstrap?(extraModules?: string[]): ng.auto.IInjectorService; 174 } 175 176 /////////////////////////////////////////////////////////////////////////// 177 // Module 178 // see http://docs.angularjs.org/api/angular.Module 179 /////////////////////////////////////////////////////////////////////////// 180 interface IModule { 181 animation(name: string, animationFactory: Function): IModule; 182 animation(name: string, inlineAnnotatedFunction: any[]): IModule; 183 animation(object: Object): IModule; 184 /** 185 * Use this method to register a component. 186 * 187 * @param name The name of the component. 188 * @param options A definition object passed into the component. 189 */ 190 component(name: string, options: IComponentOptions): IModule; 191 /** 192 * Use this method to register work which needs to be performed on module loading. 193 * 194 * @param configFn Execute this function on module load. Useful for service configuration. 195 */ 196 config(configFn: Function): IModule; 197 /** 198 * Use this method to register work which needs to be performed on module loading. 199 * 200 * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration. 201 */ 202 config(inlineAnnotatedFunction: any[]): IModule; 203 config(object: Object): IModule; 204 /** 205 * 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. 206 * 207 * @param name The name of the constant. 208 * @param value The constant value. 209 */ 210 constant(name: string, value: any): IModule; 211 constant(object: Object): IModule; 212 /** 213 * The $controller service is used by Angular to create new controllers. 214 * 215 * This provider allows controller registration via the register method. 216 * 217 * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. 218 * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). 219 */ 220 controller(name: string, controllerConstructor: Function): IModule; 221 /** 222 * The $controller service is used by Angular to create new controllers. 223 * 224 * This provider allows controller registration via the register method. 225 * 226 * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. 227 * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). 228 */ 229 controller(name: string, inlineAnnotatedConstructor: any[]): IModule; 230 controller(object: Object): IModule; 231 /** 232 * Register a new directive with the compiler. 233 * 234 * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) 235 * @param directiveFactory An injectable directive factory function. 236 */ 237 directive(name: string, directiveFactory: IDirectiveFactory): IModule; 238 /** 239 * Register a new directive with the compiler. 240 * 241 * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) 242 * @param directiveFactory An injectable directive factory function. 243 */ 244 directive(name: string, inlineAnnotatedFunction: any[]): IModule; 245 directive(object: Object): IModule; 246 /** 247 * 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. 248 * 249 * @param name The name of the instance. 250 * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). 251 */ 252 factory(name: string, $getFn: Function): IModule; 253 /** 254 * 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. 255 * 256 * @param name The name of the instance. 257 * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). 258 */ 259 factory(name: string, inlineAnnotatedFunction: any[]): IModule; 260 factory(object: Object): IModule; 261 filter(name: string, filterFactoryFunction: Function): IModule; 262 filter(name: string, inlineAnnotatedFunction: any[]): IModule; 263 filter(object: Object): IModule; 264 provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule; 265 provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; 266 provider(name: string, inlineAnnotatedConstructor: any[]): IModule; 267 provider(name: string, providerObject: IServiceProvider): IModule; 268 provider(object: Object): IModule; 269 /** 270 * 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. 271 */ 272 run(initializationFunction: Function): IModule; 273 /** 274 * 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. 275 */ 276 run(inlineAnnotatedFunction: any[]): IModule; 277 service(name: string, serviceConstructor: Function): IModule; 278 service(name: string, inlineAnnotatedConstructor: any[]): IModule; 279 service(object: Object): IModule; 280 /** 281 * 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. 282 283 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. 284 * 285 * @param name The name of the instance. 286 * @param value The value. 287 */ 288 value(name: string, value: any): IModule; 289 value(object: Object): IModule; 290 291 /** 292 * 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. 293 * @param name The name of the service to decorate 294 * @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. 295 */ 296 decorator(name:string, decoratorConstructor: Function): IModule; 297 decorator(name:string, inlineAnnotatedConstructor: any[]): IModule; 298 299 // Properties 300 name: string; 301 requires: string[]; 302 } 303 304 /////////////////////////////////////////////////////////////////////////// 305 // Attributes 306 // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes 307 /////////////////////////////////////////////////////////////////////////// 308 interface IAttributes { 309 /** 310 * this is necessary to be able to access the scoped attributes. it's not very elegant 311 * because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way 312 * this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 313 */ 314 [name: string]: any; 315 316 /** 317 * Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with x- or data-) to its normalized, camelCase form. 318 * 319 * Also there is special case for Moz prefix starting with upper case letter. 320 * 321 * For further information check out the guide on @see https://docs.angularjs.org/guide/directive#matching-directives 322 */ 323 $normalize(name: string): string; 324 325 /** 326 * Adds the CSS class value specified by the classVal parameter to the 327 * element. If animations are enabled then an animation will be triggered 328 * for the class addition. 329 */ 330 $addClass(classVal: string): void; 331 332 /** 333 * Removes the CSS class value specified by the classVal parameter from the 334 * element. If animations are enabled then an animation will be triggered for 335 * the class removal. 336 */ 337 $removeClass(classVal: string): void; 338 339 /** 340 * Set DOM element attribute value. 341 */ 342 $set(key: string, value: any): void; 343 344 /** 345 * Observes an interpolated attribute. 346 * The observer function will be invoked once during the next $digest 347 * following compilation. The observer is then invoked whenever the 348 * interpolated value changes. 349 */ 350 $observe<T>(name: string, fn: (value?: T) => any): Function; 351 352 /** 353 * A map of DOM element attribute names to the normalized name. This is needed 354 * to do reverse lookup from normalized name back to actual name. 355 */ 356 $attr: Object; 357 } 358 359 /** 360 * form.FormController - type in module ng 361 * see https://docs.angularjs.org/api/ng/type/form.FormController 362 */ 363 interface IFormController { 364 365 /** 366 * 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 367 */ 368 [name: string]: any; 369 370 $pristine: boolean; 371 $dirty: boolean; 372 $valid: boolean; 373 $invalid: boolean; 374 $submitted: boolean; 375 $error: any; 376 $addControl(control: INgModelController): void; 377 $removeControl(control: INgModelController): void; 378 $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController): void; 379 $setDirty(): void; 380 $setPristine(): void; 381 $commitViewValue(): void; 382 $rollbackViewValue(): void; 383 $setSubmitted(): void; 384 $setUntouched(): void; 385 } 386 387 /////////////////////////////////////////////////////////////////////////// 388 // NgModelController 389 // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController 390 /////////////////////////////////////////////////////////////////////////// 391 interface INgModelController { 392 $render(): void; 393 $setValidity(validationErrorKey: string, isValid: boolean): void; 394 // Documentation states viewValue and modelValue to be a string but other 395 // types do work and it's common to use them. 396 $setViewValue(value: any, trigger?: string): void; 397 $setPristine(): void; 398 $setDirty(): void; 399 $validate(): void; 400 $setTouched(): void; 401 $setUntouched(): void; 402 $rollbackViewValue(): void; 403 $commitViewValue(): void; 404 $isEmpty(value: any): boolean; 405 406 $viewValue: any; 407 408 $modelValue: any; 409 410 $parsers: IModelParser[]; 411 $formatters: IModelFormatter[]; 412 $viewChangeListeners: IModelViewChangeListener[]; 413 $error: any; 414 $name: string; 415 416 $touched: boolean; 417 $untouched: boolean; 418 419 $validators: IModelValidators; 420 $asyncValidators: IAsyncModelValidators; 421 422 $pending: any; 423 $pristine: boolean; 424 $dirty: boolean; 425 $valid: boolean; 426 $invalid: boolean; 427 } 428 429 interface IModelValidators { 430 /** 431 * viewValue is any because it can be an object that is called in the view like $viewValue.name:$viewValue.subName 432 */ 433 [index: string]: (modelValue: any, viewValue: any) => boolean; 434 } 435 436 interface IAsyncModelValidators { 437 [index: string]: (modelValue: any, viewValue: any) => IPromise<any>; 438 } 439 440 interface IModelParser { 441 (value: any): any; 442 } 443 444 interface IModelFormatter { 445 (value: any): any; 446 } 447 448 interface IModelViewChangeListener { 449 (): void; 450 } 451 452 /** 453 * $rootScope - $rootScopeProvider - service in module ng 454 * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope 455 */ 456 interface IRootScopeService { 457 [index: string]: any; 458 459 $apply(): any; 460 $apply(exp: string): any; 461 $apply(exp: (scope: IScope) => any): any; 462 463 $applyAsync(): any; 464 $applyAsync(exp: string): any; 465 $applyAsync(exp: (scope: IScope) => any): any; 466 467 /** 468 * Dispatches an event name downwards to all child scopes (and their children) notifying the registered $rootScope.Scope listeners. 469 * 470 * 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. 471 * 472 * Any exception emitted from the listeners will be passed onto the $exceptionHandler service. 473 * 474 * @param name Event name to broadcast. 475 * @param args Optional one or more arguments which will be passed onto the event listeners. 476 */ 477 $broadcast(name: string, ...args: any[]): IAngularEvent; 478 $destroy(): void; 479 $digest(): void; 480 /** 481 * Dispatches an event name upwards through the scope hierarchy notifying the registered $rootScope.Scope listeners. 482 * 483 * 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. 484 * 485 * Any exception emitted from the listeners will be passed onto the $exceptionHandler service. 486 * 487 * @param name Event name to emit. 488 * @param args Optional one or more arguments which will be passed onto the event listeners. 489 */ 490 $emit(name: string, ...args: any[]): IAngularEvent; 491 492 $eval(): any; 493 $eval(expression: string, locals?: Object): any; 494 $eval(expression: (scope: IScope) => any, locals?: Object): any; 495 496 $evalAsync(): void; 497 $evalAsync(expression: string): void; 498 $evalAsync(expression: (scope: IScope) => any): void; 499 500 // Defaults to false by the implementation checking strategy 501 $new(isolate?: boolean, parent?: IScope): IScope; 502 503 /** 504 * Listens on events of a given type. See $emit for discussion of event life cycle. 505 * 506 * The event listener function format is: function(event, args...). 507 * 508 * @param name Event name to listen on. 509 * @param listener Function to call when the event is emitted. 510 */ 511 $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; 512 513 $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; 514 $watch<T>(watchExpression: string, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function; 515 $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; 516 $watch<T>(watchExpression: (scope: IScope) => T, listener?: (newValue: T, oldValue: T, scope: IScope) => any, objectEquality?: boolean): Function; 517 518 $watchCollection<T>(watchExpression: string, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function; 519 $watchCollection<T>(watchExpression: (scope: IScope) => T, listener: (newValue: T, oldValue: T, scope: IScope) => any): Function; 520 521 $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; 522 $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; 523 524 $parent: IScope; 525 $root: IRootScopeService; 526 $id: number; 527 528 // Hidden members 529 $$isolateBindings: any; 530 $$phase: any; 531 } 532 533 interface IScope extends IRootScopeService { } 534 535 /** 536 * $scope for ngRepeat directive. 537 * see https://docs.angularjs.org/api/ng/directive/ngRepeat 538 */ 539 interface IRepeatScope extends IScope { 540 541 /** 542 * iterator offset of the repeated element (0..length-1). 543 */ 544 $index: number; 545 546 /** 547 * true if the repeated element is first in the iterator. 548 */ 549 $first: boolean; 550 551 /** 552 * true if the repeated element is between the first and last in the iterator. 553 */ 554 $middle: boolean; 555 556 /** 557 * true if the repeated element is last in the iterator. 558 */ 559 $last: boolean; 560 561 /** 562 * true if the iterator position $index is even (otherwise false). 563 */ 564 $even: boolean; 565 566 /** 567 * true if the iterator position $index is odd (otherwise false). 568 */ 569 $odd: boolean; 570 571 } 572 573 interface IAngularEvent { 574 /** 575 * the scope on which the event was $emit-ed or $broadcast-ed. 576 */ 577 targetScope: IScope; 578 /** 579 * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null. 580 */ 581 currentScope: IScope; 582 /** 583 * name of the event. 584 */ 585 name: string; 586 /** 587 * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed). 588 */ 589 stopPropagation?: Function; 590 /** 591 * calling preventDefault sets defaultPrevented flag to true. 592 */ 593 preventDefault: Function; 594 /** 595 * true if preventDefault was called. 596 */ 597 defaultPrevented: boolean; 598 } 599 600 /////////////////////////////////////////////////////////////////////////// 601 // WindowService 602 // see http://docs.angularjs.org/api/ng.$window 603 /////////////////////////////////////////////////////////////////////////// 604 interface IWindowService extends Window { 605 [key: string]: any; 606 } 607 608 /////////////////////////////////////////////////////////////////////////// 609 // BrowserService 610 // TODO undocumented, so we need to get it from the source code 611 /////////////////////////////////////////////////////////////////////////// 612 interface IBrowserService { 613 defer: angular.ITimeoutService; 614 [key: string]: any; 615 } 616 617 /////////////////////////////////////////////////////////////////////////// 618 // TimeoutService 619 // see http://docs.angularjs.org/api/ng.$timeout 620 /////////////////////////////////////////////////////////////////////////// 621 interface ITimeoutService { 622 (delay?: number, invokeApply?: boolean): IPromise<void>; 623 <T>(fn: (...args: any[]) => T, delay?: number, invokeApply?: boolean, ...args: any[]): IPromise<T>; 624 cancel(promise?: IPromise<any>): boolean; 625 } 626 627 /////////////////////////////////////////////////////////////////////////// 628 // IntervalService 629 // see http://docs.angularjs.org/api/ng.$interval 630 /////////////////////////////////////////////////////////////////////////// 631 interface IIntervalService { 632 (func: Function, delay: number, count?: number, invokeApply?: boolean, ...args: any[]): IPromise<any>; 633 cancel(promise: IPromise<any>): boolean; 634 } 635 636 /////////////////////////////////////////////////////////////////////////// 637 // AnimateProvider 638 // see http://docs.angularjs.org/api/ng/provider/$animateProvider 639 /////////////////////////////////////////////////////////////////////////// 640 interface IAnimateProvider { 641 /** 642 * Registers a new injectable animation factory function. 643 * 644 * @param name The name of the animation. 645 * @param factory The factory function that will be executed to return the animation object. 646 */ 647 register(name: string, factory: () => IAnimateCallbackObject): void; 648 649 /** 650 * Gets and/or sets the CSS class expression that is checked when performing an animation. 651 * 652 * @param expression The className expression which will be checked against all animations. 653 * @returns The current CSS className expression value. If null then there is no expression value. 654 */ 655 classNameFilter(expression?: RegExp): RegExp; 656 } 657 658 /** 659 * The animation object which contains callback functions for each event that is expected to be animated. 660 */ 661 interface IAnimateCallbackObject { 662 eventFn(element: Node, doneFn: () => void): Function; 663 } 664 665 /** 666 * $filter - $filterProvider - service in module ng 667 * 668 * Filters are used for formatting data displayed to the user. 669 * 670 * see https://docs.angularjs.org/api/ng/service/$filter 671 */ 672 interface IFilterService { 673 (name: 'filter'): IFilterFilter; 674 (name: 'currency'): IFilterCurrency; 675 (name: 'number'): IFilterNumber; 676 (name: 'date'): IFilterDate; 677 (name: 'json'): IFilterJson; 678 (name: 'lowercase'): IFilterLowercase; 679 (name: 'uppercase'): IFilterUppercase; 680 (name: 'limitTo'): IFilterLimitTo; 681 (name: 'orderBy'): IFilterOrderBy; 682 /** 683 * Usage: 684 * $filter(name); 685 * 686 * @param name Name of the filter function to retrieve 687 */ 688 <T>(name: string): T; 689 } 690 691 interface IFilterFilter { 692 <T>(array: T[], expression: string | IFilterFilterPatternObject | IFilterFilterPredicateFunc<T>, comparator?: IFilterFilterComparatorFunc<T>|boolean): T[]; 693 } 694 695 interface IFilterFilterPatternObject { 696 [name: string]: any; 697 } 698 699 interface IFilterFilterPredicateFunc<T> { 700 (value: T, index: number, array: T[]): boolean; 701 } 702 703 interface IFilterFilterComparatorFunc<T> { 704 (actual: T, expected: T): boolean; 705 } 706 707 interface IFilterCurrency { 708 /** 709 * Formats a number as a currency (ie $1,234.56). When no currency symbol is provided, default symbol for current locale is used. 710 * @param amount Input to filter. 711 * @param symbol Currency symbol or identifier to be displayed. 712 * @param fractionSize Number of decimal places to round the amount to, defaults to default max fraction size for current locale 713 * @return Formatted number 714 */ 715 (amount: number, symbol?: string, fractionSize?: number): string; 716 } 717 718 interface IFilterNumber { 719 /** 720 * Formats a number as text. 721 * @param number Number to format. 722 * @param fractionSize Number of decimal places to round the number to. If this is not provided then the fraction size is computed from the current locale's number formatting pattern. In the case of the default locale, it will be 3. 723 * @return Number rounded to decimalPlaces and places a “,” after each third digit. 724 */ 725 (value: number|string, fractionSize?: number|string): string; 726 } 727 728 interface IFilterDate { 729 /** 730 * Formats date to a string based on the requested format. 731 * 732 * @param date Date to format either as Date object, milliseconds (string or number) or various ISO 8601 datetime string formats (e.g. yyyy-MM-ddTHH:mm:ss.sssZ and its shorter versions like yyyy-MM-ddTHH:mmZ, yyyy-MM-dd or yyyyMMddTHHmmssZ). If no timezone is specified in the string input, the time is considered to be in the local timezone. 733 * @param format Formatting rules (see Description). If not specified, mediumDate is used. 734 * @param timezone Timezone to be used for formatting. It understands UTC/GMT and the continental US time zone abbreviations, but for general use, use a time zone offset, for example, '+0430' (4 hours, 30 minutes east of the Greenwich meridian) If not specified, the timezone of the browser will be used. 735 * @return Formatted string or the input if input is not recognized as date/millis. 736 */ 737 (date: Date | number | string, format?: string, timezone?: string): string; 738 } 739 740 interface IFilterJson { 741 /** 742 * Allows you to convert a JavaScript object into JSON string. 743 * @param object Any JavaScript object (including arrays and primitive types) to filter. 744 * @param spacing The number of spaces to use per indentation, defaults to 2. 745 * @return JSON string. 746 */ 747 (object: any, spacing?: number): string; 748 } 749 750 interface IFilterLowercase { 751 /** 752 * Converts string to lowercase. 753 */ 754 (value: string): string; 755 } 756 757 interface IFilterUppercase { 758 /** 759 * Converts string to uppercase. 760 */ 761 (value: string): string; 762 } 763 764 interface IFilterLimitTo { 765 /** 766 * Creates a new array containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array, string or number, as specified by the value and sign (positive or negative) of limit. 767 * @param input Source array to be limited. 768 * @param limit The length of the returned array. If the limit number is positive, limit number of items from the beginning of the source array/string are copied. If the number is negative, limit number of items from the end of the source array are copied. The limit will be trimmed if it exceeds array.length. If limit is undefined, the input will be returned unchanged. 769 * @param begin Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0. 770 * @return A new sub-array of length limit or less if input array had less than limit elements. 771 */ 772 <T>(input: T[], limit: string|number, begin?: string|number): T[]; 773 /** 774 * Creates a new string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source string or number, as specified by the value and sign (positive or negative) of limit. If a number is used as input, it is converted to a string. 775 * @param input Source string or number to be limited. 776 * @param limit The length of the returned string. If the limit number is positive, limit number of items from the beginning of the source string are copied. If the number is negative, limit number of items from the end of the source string are copied. The limit will be trimmed if it exceeds input.length. If limit is undefined, the input will be returned unchanged. 777 * @param begin Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0. 778 * @return A new substring of length limit or less if input had less than limit elements. 779 */ 780 (input: string|number, limit: string|number, begin?: string|number): string; 781 } 782 783 interface IFilterOrderBy { 784 /** 785 * Orders a specified array by the expression predicate. It is ordered alphabetically for strings and numerically for numbers. Note: if you notice numbers are not being sorted as expected, make sure they are actually being saved as numbers and not strings. 786 * @param array The array to sort. 787 * @param expression A predicate to be used by the comparator to determine the order of elements. 788 * @param reverse Reverse the order of the array. 789 * @return Reverse the order of the array. 790 */ 791 <T>(array: T[], expression: string|((value: T) => any)|(((value: T) => any)|string)[], reverse?: boolean): T[]; 792 } 793 794 /** 795 * $filterProvider - $filter - provider in module ng 796 * 797 * 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. 798 * 799 * see https://docs.angularjs.org/api/ng/provider/$filterProvider 800 */ 801 interface IFilterProvider extends IServiceProvider { 802 /** 803 * register(name); 804 * 805 * @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). 806 */ 807 register(name: string | {}): IServiceProvider; 808 } 809 810 /////////////////////////////////////////////////////////////////////////// 811 // LocaleService 812 // see http://docs.angularjs.org/api/ng.$locale 813 /////////////////////////////////////////////////////////////////////////// 814 interface ILocaleService { 815 id: string; 816 817 // These are not documented 818 // Check angular's i18n files for exemples 819 NUMBER_FORMATS: ILocaleNumberFormatDescriptor; 820 DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; 821 pluralCat: (num: any) => string; 822 } 823 824 interface ILocaleNumberFormatDescriptor { 825 DECIMAL_SEP: string; 826 GROUP_SEP: string; 827 PATTERNS: ILocaleNumberPatternDescriptor[]; 828 CURRENCY_SYM: string; 829 } 830 831 interface ILocaleNumberPatternDescriptor { 832 minInt: number; 833 minFrac: number; 834 maxFrac: number; 835 posPre: string; 836 posSuf: string; 837 negPre: string; 838 negSuf: string; 839 gSize: number; 840 lgSize: number; 841 } 842 843 interface ILocaleDateTimeFormatDescriptor { 844 MONTH: string[]; 845 SHORTMONTH: string[]; 846 DAY: string[]; 847 SHORTDAY: string[]; 848 AMPMS: string[]; 849 medium: string; 850 short: string; 851 fullDate: string; 852 longDate: string; 853 mediumDate: string; 854 shortDate: string; 855 mediumTime: string; 856 shortTime: string; 857 } 858 859 /////////////////////////////////////////////////////////////////////////// 860 // LogService 861 // see http://docs.angularjs.org/api/ng.$log 862 // see http://docs.angularjs.org/api/ng.$logProvider 863 /////////////////////////////////////////////////////////////////////////// 864 interface ILogService { 865 debug: ILogCall; 866 error: ILogCall; 867 info: ILogCall; 868 log: ILogCall; 869 warn: ILogCall; 870 } 871 872 interface ILogProvider extends IServiceProvider { 873 debugEnabled(): boolean; 874 debugEnabled(enabled: boolean): ILogProvider; 875 } 876 877 // We define this as separate interface so we can reopen it later for 878 // the ngMock module. 879 interface ILogCall { 880 (...args: any[]): void; 881 } 882 883 /////////////////////////////////////////////////////////////////////////// 884 // ParseService 885 // see http://docs.angularjs.org/api/ng.$parse 886 // see http://docs.angularjs.org/api/ng.$parseProvider 887 /////////////////////////////////////////////////////////////////////////// 888 interface IParseService { 889 (expression: string): ICompiledExpression; 890 } 891 892 interface IParseProvider { 893 logPromiseWarnings(): boolean; 894 logPromiseWarnings(value: boolean): IParseProvider; 895 896 unwrapPromises(): boolean; 897 unwrapPromises(value: boolean): IParseProvider; 898 } 899 900 interface ICompiledExpression { 901 (context: any, locals?: any): any; 902 903 literal: boolean; 904 constant: boolean; 905 906 // If value is not provided, undefined is gonna be used since the implementation 907 // does not check the parameter. Let's force a value for consistency. If consumer 908 // whants to undefine it, pass the undefined value explicitly. 909 assign(context: any, value: any): any; 910 } 911 912 /** 913 * $location - $locationProvider - service in module ng 914 * see https://docs.angularjs.org/api/ng/service/$location 915 */ 916 interface ILocationService { 917 absUrl(): string; 918 hash(): string; 919 hash(newHash: string): ILocationService; 920 host(): string; 921 922 /** 923 * Return path of current url 924 */ 925 path(): string; 926 927 /** 928 * Change path when called with parameter and return $location. 929 * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing. 930 * 931 * @param path New path 932 */ 933 path(path: string): ILocationService; 934 935 port(): number; 936 protocol(): string; 937 replace(): ILocationService; 938 939 /** 940 * Return search part (as object) of current url 941 */ 942 search(): any; 943 944 /** 945 * Change search part when called with parameter and return $location. 946 * 947 * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value. 948 * 949 * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url. 950 */ 951 search(search: any): ILocationService; 952 953 /** 954 * Change search part when called with parameter and return $location. 955 * 956 * @param search New search params 957 * @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. 958 */ 959 search(search: string, paramValue: string|number|string[]|boolean): ILocationService; 960 961 state(): any; 962 state(state: any): ILocationService; 963 url(): string; 964 url(url: string): ILocationService; 965 } 966 967 interface ILocationProvider extends IServiceProvider { 968 hashPrefix(): string; 969 hashPrefix(prefix: string): ILocationProvider; 970 html5Mode(): boolean; 971 972 // Documentation states that parameter is string, but 973 // implementation tests it as boolean, which makes more sense 974 // since this is a toggler 975 html5Mode(active: boolean): ILocationProvider; 976 html5Mode(mode: { enabled?: boolean; requireBase?: boolean; rewriteLinks?: boolean; }): ILocationProvider; 977 } 978 979 /////////////////////////////////////////////////////////////////////////// 980 // DocumentService 981 // see http://docs.angularjs.org/api/ng.$document 982 /////////////////////////////////////////////////////////////////////////// 983 interface IDocumentService extends IAugmentedJQuery {} 984 985 /////////////////////////////////////////////////////////////////////////// 986 // ExceptionHandlerService 987 // see http://docs.angularjs.org/api/ng.$exceptionHandler 988 /////////////////////////////////////////////////////////////////////////// 989 interface IExceptionHandlerService { 990 (exception: Error, cause?: string): void; 991 } 992 993 /////////////////////////////////////////////////////////////////////////// 994 // RootElementService 995 // see http://docs.angularjs.org/api/ng.$rootElement 996 /////////////////////////////////////////////////////////////////////////// 997 interface IRootElementService extends JQuery {} 998 999 interface IQResolveReject<T> { 1000 (): void; 1001 (value: T): void; 1002 } 1003 /** 1004 * $q - service in module ng 1005 * A promise/deferred implementation inspired by Kris Kowal's Q. 1006 * See http://docs.angularjs.org/api/ng/service/$q 1007 */ 1008 interface IQService { 1009 new <T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>; 1010 new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>; 1011 <T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>; 1012 <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>; 1013 1014 /** 1015 * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. 1016 * 1017 * 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. 1018 * 1019 * @param promises An array of promises. 1020 */ 1021 all<T>(promises: IPromise<any>[]): IPromise<T[]>; 1022 /** 1023 * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. 1024 * 1025 * 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. 1026 * 1027 * @param promises A hash of promises. 1028 */ 1029 all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any; }>; 1030 all<T extends {}>(promises: { [id: string]: IPromise<any>; }): IPromise<T>; 1031 /** 1032 * Creates a Deferred object which represents a task which will finish in the future. 1033 */ 1034 defer<T>(): IDeferred<T>; 1035 /** 1036 * 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. 1037 * 1038 * 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. 1039 * 1040 * @param reason Constant, message, exception or an object representing the rejection reason. 1041 */ 1042 reject(reason?: any): IPromise<any>; 1043 /** 1044 * 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. 1045 * 1046 * @param value Value or a promise 1047 */ 1048 resolve<T>(value: IPromise<T>|T): IPromise<T>; 1049 /** 1050 * 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. 1051 */ 1052 resolve(): IPromise<void>; 1053 /** 1054 * 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. 1055 * 1056 * @param value Value or a promise 1057 */ 1058 when<T>(value: IPromise<T>|T): IPromise<T>; 1059 /** 1060 * 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. 1061 */ 1062 when(): IPromise<void>; 1063 } 1064 1065 interface IPromise<T> { 1066 /** 1067 * 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. 1068 * The successCallBack may return IPromise<void> for when a $q.reject() needs to be returned 1069 * 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. 1070 */ 1071 then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>; 1072 1073 /** 1074 * Shorthand for promise.then(null, errorCallback) 1075 */ 1076 catch<TResult>(onRejected: (reason: any) => IPromise<TResult>|TResult): IPromise<TResult>; 1077 1078 /** 1079 * 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. 1080 * 1081 * 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. 1082 */ 1083 finally(finallyCallback: () => any): IPromise<T>; 1084 } 1085 1086 interface IDeferred<T> { 1087 resolve(value?: T|IPromise<T>): void; 1088 reject(reason?: any): void; 1089 notify(state?: any): void; 1090 promise: IPromise<T>; 1091 } 1092 1093 /////////////////////////////////////////////////////////////////////////// 1094 // AnchorScrollService 1095 // see http://docs.angularjs.org/api/ng.$anchorScroll 1096 /////////////////////////////////////////////////////////////////////////// 1097 interface IAnchorScrollService { 1098 (): void; 1099 (hash: string): void; 1100 yOffset: any; 1101 } 1102 1103 interface IAnchorScrollProvider extends IServiceProvider { 1104 disableAutoScrolling(): void; 1105 } 1106 1107 /** 1108 * $cacheFactory - service in module ng 1109 * 1110 * Factory that constructs Cache objects and gives access to them. 1111 * 1112 * see https://docs.angularjs.org/api/ng/service/$cacheFactory 1113 */ 1114 interface ICacheFactoryService { 1115 /** 1116 * Factory that constructs Cache objects and gives access to them. 1117 * 1118 * @param cacheId Name or id of the newly created cache. 1119 * @param optionsMap Options object that specifies the cache behavior. Properties: 1120 * 1121 * capacity — turns the cache into LRU cache. 1122 */ 1123 (cacheId: string, optionsMap?: { capacity?: number; }): ICacheObject; 1124 1125 /** 1126 * Get information about all the caches that have been created. 1127 * @returns key-value map of cacheId to the result of calling cache#info 1128 */ 1129 info(): any; 1130 1131 /** 1132 * Get access to a cache object by the cacheId used when it was created. 1133 * 1134 * @param cacheId Name or id of a cache to access. 1135 */ 1136 get(cacheId: string): ICacheObject; 1137 } 1138 1139 /** 1140 * $cacheFactory.Cache - type in module ng 1141 * 1142 * A cache object used to store and retrieve data, primarily used by $http and the script directive to cache templates and other data. 1143 * 1144 * see https://docs.angularjs.org/api/ng/type/$cacheFactory.Cache 1145 */ 1146 interface ICacheObject { 1147 /** 1148 * Retrieve information regarding a particular Cache. 1149 */ 1150 info(): { 1151 /** 1152 * the id of the cache instance 1153 */ 1154 id: string; 1155 1156 /** 1157 * the number of entries kept in the cache instance 1158 */ 1159 size: number; 1160 1161 //...: any additional properties from the options object when creating the cache. 1162 }; 1163 1164 /** 1165 * 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. 1166 * 1167 * It will not insert undefined values into the cache. 1168 * 1169 * @param key the key under which the cached data is stored. 1170 * @param value the value to store alongside the key. If it is undefined, the key will not be stored. 1171 */ 1172 put<T>(key: string, value?: T): T; 1173 1174 /** 1175 * Retrieves named data stored in the Cache object. 1176 * 1177 * @param key the key of the data to be retrieved 1178 */ 1179 get<T>(key: string): T; 1180 1181 /** 1182 * Removes an entry from the Cache object. 1183 * 1184 * @param key the key of the entry to be removed 1185 */ 1186 remove(key: string): void; 1187 1188 /** 1189 * Clears the cache object of any entries. 1190 */ 1191 removeAll(): void; 1192 1193 /** 1194 * Destroys the Cache object entirely, removing it from the $cacheFactory set. 1195 */ 1196 destroy(): void; 1197 } 1198 1199 /////////////////////////////////////////////////////////////////////////// 1200 // CompileService 1201 // see http://docs.angularjs.org/api/ng.$compile 1202 // see http://docs.angularjs.org/api/ng.$compileProvider 1203 /////////////////////////////////////////////////////////////////////////// 1204 interface ICompileService { 1205 (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; 1206 (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; 1207 (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; 1208 } 1209 1210 interface ICompileProvider extends IServiceProvider { 1211 directive(name: string, directiveFactory: Function): ICompileProvider; 1212 1213 // Undocumented, but it is there... 1214 directive(directivesMap: any): ICompileProvider; 1215 1216 aHrefSanitizationWhitelist(): RegExp; 1217 aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider; 1218 1219 imgSrcSanitizationWhitelist(): RegExp; 1220 imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider; 1221 1222 debugInfoEnabled(enabled?: boolean): any; 1223 } 1224 1225 interface ICloneAttachFunction { 1226 // Let's hint but not force cloneAttachFn's signature 1227 (clonedElement?: JQuery, scope?: IScope): any; 1228 } 1229 1230 // This corresponds to the "publicLinkFn" returned by $compile. 1231 interface ITemplateLinkingFunction { 1232 (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; 1233 } 1234 1235 // This corresponds to $transclude (and also the transclude function passed to link). 1236 interface ITranscludeFunction { 1237 // If the scope is provided, then the cloneAttachFn must be as well. 1238 (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery; 1239 // If one argument is provided, then it's assumed to be the cloneAttachFn. 1240 (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; 1241 } 1242 1243 /////////////////////////////////////////////////////////////////////////// 1244 // ControllerService 1245 // see http://docs.angularjs.org/api/ng.$controller 1246 // see http://docs.angularjs.org/api/ng.$controllerProvider 1247 /////////////////////////////////////////////////////////////////////////// 1248 interface IControllerService { 1249 // Although the documentation doesn't state this, locals are optional 1250 <T>(controllerConstructor: new (...args: any[]) => T, locals?: any, bindToController?: any): T; 1251 <T>(controllerConstructor: Function, locals?: any, bindToController?: any): T; 1252 <T>(controllerName: string, locals?: any, bindToController?: any): T; 1253 } 1254 1255 interface IControllerProvider extends IServiceProvider { 1256 register(name: string, controllerConstructor: Function): void; 1257 register(name: string, dependencyAnnotatedConstructor: any[]): void; 1258 allowGlobals(): void; 1259 } 1260 1261 /** 1262 * HttpService 1263 * see http://docs.angularjs.org/api/ng/service/$http 1264 */ 1265 interface IHttpService { 1266 /** 1267 * Object describing the request to be made and how it should be processed. 1268 */ 1269 <T>(config: IRequestConfig): IHttpPromise<T>; 1270 1271 /** 1272 * Shortcut method to perform GET request. 1273 * 1274 * @param url Relative or absolute URL specifying the destination of the request 1275 * @param config Optional configuration object 1276 */ 1277 get<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>; 1278 1279 /** 1280 * Shortcut method to perform DELETE request. 1281 * 1282 * @param url Relative or absolute URL specifying the destination of the request 1283 * @param config Optional configuration object 1284 */ 1285 delete<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>; 1286 1287 /** 1288 * Shortcut method to perform HEAD request. 1289 * 1290 * @param url Relative or absolute URL specifying the destination of the request 1291 * @param config Optional configuration object 1292 */ 1293 head<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>; 1294 1295 /** 1296 * Shortcut method to perform JSONP request. 1297 * 1298 * @param url Relative or absolute URL specifying the destination of the request 1299 * @param config Optional configuration object 1300 */ 1301 jsonp<T>(url: string, config?: IRequestShortcutConfig): IHttpPromise<T>; 1302 1303 /** 1304 * Shortcut method to perform POST request. 1305 * 1306 * @param url Relative or absolute URL specifying the destination of the request 1307 * @param data Request content 1308 * @param config Optional configuration object 1309 */ 1310 post<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>; 1311 1312 /** 1313 * Shortcut method to perform PUT request. 1314 * 1315 * @param url Relative or absolute URL specifying the destination of the request 1316 * @param data Request content 1317 * @param config Optional configuration object 1318 */ 1319 put<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>; 1320 1321 /** 1322 * Shortcut method to perform PATCH request. 1323 * 1324 * @param url Relative or absolute URL specifying the destination of the request 1325 * @param data Request content 1326 * @param config Optional configuration object 1327 */ 1328 patch<T>(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise<T>; 1329 1330 /** 1331 * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. 1332 */ 1333 defaults: IHttpProviderDefaults; 1334 1335 /** 1336 * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes. 1337 */ 1338 pendingRequests: IRequestConfig[]; 1339 } 1340 1341 /** 1342 * Object describing the request to be made and how it should be processed. 1343 * see http://docs.angularjs.org/api/ng/service/$http#usage 1344 */ 1345 interface IRequestShortcutConfig extends IHttpProviderDefaults { 1346 /** 1347 * {Object.<string|Object>} 1348 * 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. 1349 */ 1350 params?: any; 1351 1352 /** 1353 * {string|Object} 1354 * Data to be sent as the request message data. 1355 */ 1356 data?: any; 1357 1358 /** 1359 * Timeout in milliseconds, or promise that should abort the request when resolved. 1360 */ 1361 timeout?: number|IPromise<any>; 1362 1363 /** 1364 * See [XMLHttpRequest.responseType]https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#xmlhttprequest-responsetype 1365 */ 1366 responseType?: string; 1367 } 1368 1369 /** 1370 * Object describing the request to be made and how it should be processed. 1371 * see http://docs.angularjs.org/api/ng/service/$http#usage 1372 */ 1373 interface IRequestConfig extends IRequestShortcutConfig { 1374 /** 1375 * HTTP method (e.g. 'GET', 'POST', etc) 1376 */ 1377 method: string; 1378 /** 1379 * Absolute or relative URL of the resource that is being requested. 1380 */ 1381 url: string; 1382 } 1383 1384 interface IHttpHeadersGetter { 1385 (): { [name: string]: string; }; 1386 (headerName: string): string; 1387 } 1388 1389 interface IHttpPromiseCallback<T> { 1390 (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void; 1391 } 1392 1393 interface IHttpPromiseCallbackArg<T> { 1394 data?: T; 1395 status?: number; 1396 headers?: IHttpHeadersGetter; 1397 config?: IRequestConfig; 1398 statusText?: string; 1399 } 1400 1401 interface IHttpPromise<T> extends IPromise<IHttpPromiseCallbackArg<T>> { 1402 success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>; 1403 error(callback: IHttpPromiseCallback<any>): IHttpPromise<T>; 1404 } 1405 1406 // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228 1407 interface IHttpRequestTransformer { 1408 (data: any, headersGetter: IHttpHeadersGetter): any; 1409 } 1410 1411 // The definition of fields are the same as IHttpPromiseCallbackArg 1412 interface IHttpResponseTransformer { 1413 (data: any, headersGetter: IHttpHeadersGetter, status: number): any; 1414 } 1415 1416 interface IHttpRequestConfigHeaders { 1417 [requestType: string]: string|(() => string); 1418 common?: string|(() => string); 1419 get?: string|(() => string); 1420 post?: string|(() => string); 1421 put?: string|(() => string); 1422 patch?: string|(() => string); 1423 } 1424 1425 /** 1426 * Object that controls the defaults for $http provider. Not all fields of IRequestShortcutConfig can be configured 1427 * via defaults and the docs do not say which. The following is based on the inspection of the source code. 1428 * https://docs.angularjs.org/api/ng/service/$http#defaults 1429 * https://docs.angularjs.org/api/ng/service/$http#usage 1430 * https://docs.angularjs.org/api/ng/provider/$httpProvider The properties section 1431 */ 1432 interface IHttpProviderDefaults { 1433 /** 1434 * {boolean|Cache} 1435 * 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. 1436 */ 1437 cache?: any; 1438 1439 /** 1440 * Transform function or an array of such functions. The transform function takes the http request body and 1441 * headers and returns its transformed (typically serialized) version. 1442 * @see {@link https://docs.angularjs.org/api/ng/service/$http#transforming-requests-and-responses} 1443 */ 1444 transformRequest?: IHttpRequestTransformer |IHttpRequestTransformer[]; 1445 1446 /** 1447 * Transform function or an array of such functions. The transform function takes the http response body and 1448 * headers and returns its transformed (typically deserialized) version. 1449 */ 1450 transformResponse?: IHttpResponseTransformer | IHttpResponseTransformer[]; 1451 1452 /** 1453 * Map of strings or functions which return strings representing HTTP headers to send to the server. If the 1454 * return value of a function is null, the header will not be sent. 1455 * The key of the map is the request verb in lower case. The "common" key applies to all requests. 1456 * @see {@link https://docs.angularjs.org/api/ng/service/$http#setting-http-headers} 1457 */ 1458 headers?: IHttpRequestConfigHeaders; 1459 1460 /** Name of HTTP header to populate with the XSRF token. */ 1461 xsrfHeaderName?: string; 1462 1463 /** Name of cookie containing the XSRF token. */ 1464 xsrfCookieName?: string; 1465 1466 /** 1467 * 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. 1468 */ 1469 withCredentials?: boolean; 1470 1471 /** 1472 * A function used to the prepare string representation of request parameters (specified as an object). If 1473 * specified as string, it is interpreted as a function registered with the $injector. Defaults to 1474 * $httpParamSerializer. 1475 */ 1476 paramSerializer?: string | ((obj: any) => string); 1477 } 1478 1479 interface IHttpInterceptor { 1480 request?: (config: IRequestConfig) => IRequestConfig|IPromise<IRequestConfig>; 1481 requestError?: (rejection: any) => any; 1482 response?: <T>(response: IHttpPromiseCallbackArg<T>) => IPromise<T>|T; 1483 responseError?: (rejection: any) => any; 1484 } 1485 1486 interface IHttpInterceptorFactory { 1487 (...args: any[]): IHttpInterceptor; 1488 } 1489 1490 interface IHttpProvider extends IServiceProvider { 1491 defaults: IHttpProviderDefaults; 1492 1493 /** 1494 * Register service factories (names or implementations) for interceptors which are called before and after 1495 * each request. 1496 */ 1497 interceptors: (string|IHttpInterceptorFactory|(string|IHttpInterceptorFactory)[])[]; 1498 useApplyAsync(): boolean; 1499 useApplyAsync(value: boolean): IHttpProvider; 1500 1501 /** 1502 * 1503 * @param {boolean=} value If true, `$http` will return a normal promise without the `success` and `error` methods. 1504 * @returns {boolean|Object} If a value is specified, returns the $httpProvider for chaining. 1505 * otherwise, returns the current configured value. 1506 */ 1507 useLegacyPromiseExtensions(value:boolean) : boolean | IHttpProvider; 1508 } 1509 1510 /////////////////////////////////////////////////////////////////////////// 1511 // HttpBackendService 1512 // see http://docs.angularjs.org/api/ng.$httpBackend 1513 // You should never need to use this service directly. 1514 /////////////////////////////////////////////////////////////////////////// 1515 interface IHttpBackendService { 1516 // XXX Perhaps define callback signature in the future 1517 (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; 1518 } 1519 1520 /////////////////////////////////////////////////////////////////////////// 1521 // InterpolateService 1522 // see http://docs.angularjs.org/api/ng.$interpolate 1523 // see http://docs.angularjs.org/api/ng.$interpolateProvider 1524 /////////////////////////////////////////////////////////////////////////// 1525 interface IInterpolateService { 1526 (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction; 1527 endSymbol(): string; 1528 startSymbol(): string; 1529 } 1530 1531 interface IInterpolationFunction { 1532 (context: any): string; 1533 } 1534 1535 interface IInterpolateProvider extends IServiceProvider { 1536 startSymbol(): string; 1537 startSymbol(value: string): IInterpolateProvider; 1538 endSymbol(): string; 1539 endSymbol(value: string): IInterpolateProvider; 1540 } 1541 1542 /////////////////////////////////////////////////////////////////////////// 1543 // TemplateCacheService 1544 // see http://docs.angularjs.org/api/ng.$templateCache 1545 /////////////////////////////////////////////////////////////////////////// 1546 interface ITemplateCacheService extends ICacheObject {} 1547 1548 /////////////////////////////////////////////////////////////////////////// 1549 // SCEService 1550 // see http://docs.angularjs.org/api/ng.$sce 1551 /////////////////////////////////////////////////////////////////////////// 1552 interface ISCEService { 1553 getTrusted(type: string, mayBeTrusted: any): any; 1554 getTrustedCss(value: any): any; 1555 getTrustedHtml(value: any): any; 1556 getTrustedJs(value: any): any; 1557 getTrustedResourceUrl(value: any): any; 1558 getTrustedUrl(value: any): any; 1559 parse(type: string, expression: string): (context: any, locals: any) => any; 1560 parseAsCss(expression: string): (context: any, locals: any) => any; 1561 parseAsHtml(expression: string): (context: any, locals: any) => any; 1562 parseAsJs(expression: string): (context: any, locals: any) => any; 1563 parseAsResourceUrl(expression: string): (context: any, locals: any) => any; 1564 parseAsUrl(expression: string): (context: any, locals: any) => any; 1565 trustAs(type: string, value: any): any; 1566 trustAsHtml(value: any): any; 1567 trustAsJs(value: any): any; 1568 trustAsResourceUrl(value: any): any; 1569 trustAsUrl(value: any): any; 1570 isEnabled(): boolean; 1571 } 1572 1573 /////////////////////////////////////////////////////////////////////////// 1574 // SCEProvider 1575 // see http://docs.angularjs.org/api/ng.$sceProvider 1576 /////////////////////////////////////////////////////////////////////////// 1577 interface ISCEProvider extends IServiceProvider { 1578 enabled(value: boolean): void; 1579 } 1580 1581 /////////////////////////////////////////////////////////////////////////// 1582 // SCEDelegateService 1583 // see http://docs.angularjs.org/api/ng.$sceDelegate 1584 /////////////////////////////////////////////////////////////////////////// 1585 interface ISCEDelegateService { 1586 getTrusted(type: string, mayBeTrusted: any): any; 1587 trustAs(type: string, value: any): any; 1588 valueOf(value: any): any; 1589 } 1590 1591 1592 /////////////////////////////////////////////////////////////////////////// 1593 // SCEDelegateProvider 1594 // see http://docs.angularjs.org/api/ng.$sceDelegateProvider 1595 /////////////////////////////////////////////////////////////////////////// 1596 interface ISCEDelegateProvider extends IServiceProvider { 1597 resourceUrlBlacklist(blacklist: any[]): void; 1598 resourceUrlWhitelist(whitelist: any[]): void; 1599 resourceUrlBlacklist(): any[]; 1600 resourceUrlWhitelist(): any[]; 1601 } 1602 1603 /** 1604 * $templateRequest service 1605 * see http://docs.angularjs.org/api/ng/service/$templateRequest 1606 */ 1607 interface ITemplateRequestService { 1608 /** 1609 * Downloads a template using $http and, upon success, stores the 1610 * contents inside of $templateCache. 1611 * 1612 * If the HTTP request fails or the response data of the HTTP request is 1613 * empty then a $compile error will be thrown (unless 1614 * {ignoreRequestError} is set to true). 1615 * 1616 * @param tpl The template URL. 1617 * @param ignoreRequestError Whether or not to ignore the exception 1618 * when the request fails or the template is 1619 * empty. 1620 * 1621 * @return A promise whose value is the template content. 1622 */ 1623 (tpl: string, ignoreRequestError?: boolean): IPromise<string>; 1624 /** 1625 * total amount of pending template requests being downloaded. 1626 * @type {number} 1627 */ 1628 totalPendingRequests: number; 1629 } 1630 1631 /////////////////////////////////////////////////////////////////////////// 1632 // Component 1633 // see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html 1634 // and http://toddmotto.com/exploring-the-angular-1-5-component-method/ 1635 /////////////////////////////////////////////////////////////////////////// 1636 /** 1637 * Runtime representation a type that a Component or other object is instances of. 1638 * 1639 * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by 1640 * the `MyCustomComponent` constructor function. 1641 */ 1642 interface Type extends Function { 1643 } 1644 1645 /** 1646 * `RouteDefinition` defines a route within a {@link RouteConfig} decorator. 1647 * 1648 * Supported keys: 1649 * - `path` or `aux` (requires exactly one of these) 1650 * - `component`, `loader`, `redirectTo` (requires exactly one of these) 1651 * - `name` or `as` (optional) (requires exactly one of these) 1652 * - `data` (optional) 1653 * 1654 * See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}. 1655 */ 1656 interface RouteDefinition { 1657 path?: string; 1658 aux?: string; 1659 component?: Type | ComponentDefinition | string; 1660 loader?: Function; 1661 redirectTo?: any[]; 1662 as?: string; 1663 name?: string; 1664 data?: any; 1665 useAsDefault?: boolean; 1666 } 1667 1668 /** 1669 * Represents either a component type (`type` is `component`) or a loader function 1670 * (`type` is `loader`). 1671 * 1672 * See also {@link RouteDefinition}. 1673 */ 1674 interface ComponentDefinition { 1675 type: string; 1676 loader?: Function; 1677 component?: Type; 1678 } 1679 1680 /** 1681 * Component definition object (a simplified directive definition object) 1682 */ 1683 interface IComponentOptions { 1684 /** 1685 * Controller constructor function that should be associated with newly created scope or the name of a registered 1686 * controller if passed as a string. Empty function by default. 1687 */ 1688 controller?: any; 1689 /** 1690 * An identifier name for a reference to the controller. If present, the controller will be published to scope under 1691 * the controllerAs name. If not present, this will default to be the same as the component name. 1692 */ 1693 controllerAs?: string; 1694 /** 1695 * html template as a string or a function that returns an html template as a string which should be used as the 1696 * contents of this component. Empty string by default. 1697 * If template is a function, then it is injected with the following locals: 1698 * $element - Current element 1699 * $attrs - Current attributes object for the element 1700 */ 1701 template?: string | Function; 1702 /** 1703 * path or function that returns a path to an html template that should be used as the contents of this component. 1704 * If templateUrl is a function, then it is injected with the following locals: 1705 * $element - Current element 1706 * $attrs - Current attributes object for the element 1707 */ 1708 templateUrl?: string | Function; 1709 /** 1710 * Define DOM attribute binding to component properties. Component properties are always bound to the component 1711 * controller and not to the scope. 1712 */ 1713 bindings?: any; 1714 /** 1715 * Whether transclusion is enabled. Enabled by default. 1716 */ 1717 transclude?: boolean; 1718 require? : Object; 1719 $canActivate?: () => boolean; 1720 $routeConfig?: RouteDefinition[]; 1721 } 1722 1723 interface IComponentTemplateFn { 1724 ( $element?: IAugmentedJQuery, $attrs?: IAttributes ): string; 1725 } 1726 1727 /////////////////////////////////////////////////////////////////////////// 1728 // Directive 1729 // see http://docs.angularjs.org/api/ng.$compileProvider#directive 1730 // and http://docs.angularjs.org/guide/directive 1731 /////////////////////////////////////////////////////////////////////////// 1732 1733 interface IDirectiveFactory { 1734 (...args: any[]): IDirective; 1735 } 1736 1737 interface IDirectiveLinkFn { 1738 ( 1739 scope: IScope, 1740 instanceElement: IAugmentedJQuery, 1741 instanceAttributes: IAttributes, 1742 controller: {}, 1743 transclude: ITranscludeFunction 1744 ): void; 1745 } 1746 1747 interface IDirectivePrePost { 1748 pre?: IDirectiveLinkFn; 1749 post?: IDirectiveLinkFn; 1750 } 1751 1752 interface IDirectiveCompileFn { 1753 ( 1754 templateElement: IAugmentedJQuery, 1755 templateAttributes: IAttributes, 1756 transclude: ITranscludeFunction 1757 ): IDirectivePrePost; 1758 } 1759 1760 interface IDirective { 1761 compile?: IDirectiveCompileFn; 1762 controller?: any; 1763 controllerAs?: string; 1764 bindToController?: boolean|Object; 1765 link?: IDirectiveLinkFn | IDirectivePrePost; 1766 name?: string; 1767 priority?: number; 1768 replace?: boolean; 1769 require? : any; 1770 restrict?: string; 1771 scope?: any; 1772 template?: string | Function; 1773 templateNamespace?: string; 1774 templateUrl?: string | Function; 1775 terminal?: boolean; 1776 transclude?: any; 1777 } 1778 1779 /** 1780 * angular.element 1781 * when calling angular.element, angular returns a jQuery object, 1782 * augmented with additional methods like e.g. scope. 1783 * see: http://docs.angularjs.org/api/angular.element 1784 */ 1785 interface IAugmentedJQueryStatic extends JQueryStatic { 1786 (selector: string, context?: any): IAugmentedJQuery; 1787 (element: Element): IAugmentedJQuery; 1788 (object: {}): IAugmentedJQuery; 1789 (elementArray: Element[]): IAugmentedJQuery; 1790 (object: JQuery): IAugmentedJQuery; 1791 (func: Function): IAugmentedJQuery; 1792 (array: any[]): IAugmentedJQuery; 1793 (): IAugmentedJQuery; 1794 } 1795 1796 interface IAugmentedJQuery extends JQuery { 1797 // TODO: events, how to define? 1798 //$destroy 1799 1800 find(selector: string): IAugmentedJQuery; 1801 find(element: any): IAugmentedJQuery; 1802 find(obj: JQuery): IAugmentedJQuery; 1803 controller(): any; 1804 controller(name: string): any; 1805 injector(): any; 1806 scope(): IScope; 1807 isolateScope(): IScope; 1808 1809 inheritedData(key: string, value: any): JQuery; 1810 inheritedData(obj: { [key: string]: any; }): JQuery; 1811 inheritedData(key?: string): any; 1812 } 1813 1814 /////////////////////////////////////////////////////////////////////////// 1815 // AUTO module (angular.js) 1816 /////////////////////////////////////////////////////////////////////////// 1817 export module auto { 1818 1819 /////////////////////////////////////////////////////////////////////// 1820 // InjectorService 1821 // see http://docs.angularjs.org/api/AUTO.$injector 1822 /////////////////////////////////////////////////////////////////////// 1823 interface IInjectorService { 1824 annotate(fn: Function): string[]; 1825 annotate(inlineAnnotatedFunction: any[]): string[]; 1826 get<T>(name: string, caller?: string): T; 1827 has(name: string): boolean; 1828 instantiate<T>(typeConstructor: Function, locals?: any): T; 1829 invoke(inlineAnnotatedFunction: any[]): any; 1830 invoke(func: Function, context?: any, locals?: any): any; 1831 } 1832 1833 /////////////////////////////////////////////////////////////////////// 1834 // ProvideService 1835 // see http://docs.angularjs.org/api/AUTO.$provide 1836 /////////////////////////////////////////////////////////////////////// 1837 interface IProvideService { 1838 // Documentation says it returns the registered instance, but actual 1839 // implementation does not return anything. 1840 // constant(name: string, value: any): any; 1841 /** 1842 * 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. 1843 * 1844 * @param name The name of the constant. 1845 * @param value The constant value. 1846 */ 1847 constant(name: string, value: any): void; 1848 1849 /** 1850 * 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. 1851 * 1852 * @param name The name of the service to decorate. 1853 * @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: 1854 * 1855 * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. 1856 */ 1857 decorator(name: string, decorator: Function): void; 1858 /** 1859 * 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. 1860 * 1861 * @param name The name of the service to decorate. 1862 * @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: 1863 * 1864 * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. 1865 */ 1866 decorator(name: string, inlineAnnotatedFunction: any[]): void; 1867 factory(name: string, serviceFactoryFunction: Function): IServiceProvider; 1868 factory(name: string, inlineAnnotatedFunction: any[]): IServiceProvider; 1869 provider(name: string, provider: IServiceProvider): IServiceProvider; 1870 provider(name: string, serviceProviderConstructor: Function): IServiceProvider; 1871 service(name: string, constructor: Function): IServiceProvider; 1872 service(name: string, inlineAnnotatedFunction: any[]): IServiceProvider; 1873 value(name: string, value: any): IServiceProvider; 1874 } 1875 1876 } 1877 }