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