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