@angular-wave/angular.ts 0.0.72 → 0.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -2
- package/package.json +1 -1
- package/src/animations/animate-js.html +5 -2
- package/src/animations/animate-queue.js +1 -1
- package/src/animations/animate.js +0 -18
- package/src/core/compile/attributes.js +8 -1
- package/src/core/compile/compile.spec.js +0 -1
- package/src/core/controller/controller.js +9 -3
- package/src/core/q/q.js +2 -1
- package/src/directive/change/change.js +3 -1
- package/src/directive/form/form.js +4 -3
- package/src/directive/list/list.js +3 -3
- package/src/directive/messages/messages.js +177 -172
- package/src/directive/model/model.js +261 -471
- package/src/directive/switch/switch.js +4 -4
- package/src/router/directives/state-directives.js +2 -9
- package/src/router/hooks/core-resolvables.js +5 -3
- package/src/router/path/path-utils.js +1 -2
- package/src/router/resolve/resolve-context.js +14 -29
- package/src/router/state/state-queue-manager.js +1 -2
- package/src/router/state/state-service.js +2 -3
- package/src/router/transition/transition.js +2 -2
- package/src/router/view/view.js +2 -8
- package/src/shared/common.js +3 -8
- package/src/shared/common.spec.js +1 -19
- package/src/shared/hof.js +1 -8
- package/src/shared/jqlite/jqlite.js +1 -1
- package/src/shared/predicates.js +3 -2
- package/src/types.js +2 -3
- package/types/animations/animate-queue.d.ts +1 -1
- package/types/core/compile/attributes.d.ts +10 -1
- package/types/core/q/q.d.ts +4 -2
- package/types/directive/form/form.d.ts +3 -1
- package/types/directive/messages/messages.d.ts +76 -0
- package/types/directive/model/model.d.ts +101 -239
- package/types/router/resolve/resolve-context.d.ts +0 -2
- package/types/router/transition/transition.d.ts +0 -1
- package/types/shared/common.d.ts +0 -3
- package/types/shared/hof.d.ts +0 -1
- package/types/shared/jqlite/jqlite.d.ts +2 -2
- package/types/types.d.ts +4 -2
|
@@ -1,32 +1,69 @@
|
|
|
1
|
+
export function ngModelDirective($rootScope: any): {
|
|
2
|
+
restrict: string;
|
|
3
|
+
require: string[];
|
|
4
|
+
controller: typeof NgModelController;
|
|
5
|
+
priority: number;
|
|
6
|
+
compile: (element: any) => {
|
|
7
|
+
pre: (scope: any, element: any, attr: any, ctrls: any) => void;
|
|
8
|
+
post: (scope: any, element: any, attr: any, ctrls: any) => void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export const ngModelMinErr: (arg0: string, ...arg1: any[]) => Error;
|
|
1
12
|
/**
|
|
2
13
|
*
|
|
3
|
-
* @
|
|
4
|
-
*
|
|
5
|
-
* @
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
* @property {*} $viewValue The actual value from the control's view.
|
|
15
|
+
*
|
|
16
|
+
* @property {*} $modelValue The value in the model that the control is bound to.
|
|
17
|
+
* @property {Array.<Function>} $parsers Array of functions to execute, as a pipeline, whenever
|
|
18
|
+
* the control updates the ngModelController with a new `$viewValue` from the DOM, usually via user input.
|
|
19
|
+
*
|
|
20
|
+
* @property {Array.<Function>} $formatters Array of functions to execute, as a pipeline, whenever
|
|
21
|
+
the bound ngModel expression changes programmatically. The `$formatters` are not called when the
|
|
22
|
+
value of the control is changed by user interaction.
|
|
23
|
+
*
|
|
24
|
+
* @property {Object.<string, (string, string) => boolean>} $validators A collection of validators that are applied whenever the model value changes.
|
|
25
|
+
* The key value within the object refers to the name of the validator while the function refers to the validation operation.
|
|
26
|
+
* The validation operation is provided with the model value as an argument and must return a true or false value depending on the response of that validation.
|
|
27
|
+
*
|
|
28
|
+
* @property {Object.<string, function(string, string) => QPromise>} $asyncValidators A collection of validations that are expected to perform an asynchronous validation (e.g. a HTTP request).
|
|
29
|
+
* The validation function that is provided is expected to return a promise when it is run during the model validation process
|
|
30
|
+
*
|
|
31
|
+
* @property {Array.<Function>} $viewChangeListeners Array of functions to execute whenever
|
|
32
|
+
* a change to {@link ngModel.NgModelController#$viewValue `$viewValue`} has caused a change
|
|
33
|
+
* to {@link ngModel.NgModelController#$modelValue `$modelValue`}.
|
|
34
|
+
* It is called with no arguments, and its return value is ignored.
|
|
35
|
+
* This can be used in place of additional $watches against the model value.
|
|
36
|
+
*
|
|
37
|
+
* @property {Object} $error An object hash with all failing validator ids as keys.
|
|
38
|
+
* @property {Object} $pending An object hash with all pending validator ids as keys.
|
|
39
|
+
*
|
|
40
|
+
* @property {boolean} $untouched True if control has not lost focus yet.
|
|
41
|
+
* @property {boolean} $touched True if control has lost focus.
|
|
42
|
+
* @property {boolean} $pristine True if user has not interacted with the control yet.
|
|
43
|
+
* @property {boolean} $dirty True if user has already interacted with the control.
|
|
44
|
+
* @property {boolean} $valid True if there is no error.
|
|
45
|
+
* @property {boolean} $invalid True if at least one error on the control.
|
|
46
|
+
* @property {string} $name The name attribute of the control.
|
|
12
47
|
*/
|
|
13
|
-
export function NgModelController($scope: any, $exceptionHandler: import("../../core/exception-handler").ErrorHandler, $attr: any, $element: any, $parse: any, $animate: any, $timeout: any, $q: any, $interpolate: any): void;
|
|
14
48
|
export class NgModelController {
|
|
49
|
+
static $inject: string[];
|
|
15
50
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {*} $scope
|
|
51
|
+
* @param {import('../../core/scope/scope').Scope} $scope
|
|
18
52
|
* @param {import('../../core/exception-handler').ErrorHandler} $exceptionHandler
|
|
19
|
-
* @param {
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
53
|
+
* @param {import('../../core/compile/attributes').Attributes} $attr
|
|
54
|
+
* @param {import('../../shared/jqlite/jqlite').JQLite} $element
|
|
55
|
+
* @param {import("../../core/parser/parse").ParseService} $parse
|
|
22
56
|
* @param {*} $animate
|
|
23
57
|
* @param {*} $timeout
|
|
24
|
-
* @param {
|
|
58
|
+
* @param {import("../../core/q/q").QPromise<any>} $q
|
|
25
59
|
* @param {*} $interpolate
|
|
26
60
|
*/
|
|
27
|
-
constructor($scope:
|
|
28
|
-
|
|
29
|
-
$
|
|
61
|
+
constructor($scope: import("../../core/scope/scope").Scope, $exceptionHandler: import("../../core/exception-handler").ErrorHandler, $attr: import("../../core/compile/attributes").Attributes, $element: import("../../shared/jqlite/jqlite").JQLite, $parse: import("../../core/parser/parse").ParseService, $animate: any, $timeout: any, $q: import("../../core/q/q").QPromise<any>, $interpolate: any);
|
|
62
|
+
/** @type {any} The actual value from the control's view */
|
|
63
|
+
$viewValue: any;
|
|
64
|
+
/** @type {any} The value in the model that the control is bound to. */
|
|
65
|
+
$modelValue: any;
|
|
66
|
+
/** @type {any} */
|
|
30
67
|
$$rawModelValue: any;
|
|
31
68
|
$validators: {};
|
|
32
69
|
$asyncValidators: {};
|
|
@@ -34,10 +71,15 @@ export class NgModelController {
|
|
|
34
71
|
$formatters: any[];
|
|
35
72
|
$viewChangeListeners: any[];
|
|
36
73
|
$untouched: boolean;
|
|
74
|
+
/** @type {boolean} */
|
|
37
75
|
$touched: boolean;
|
|
76
|
+
/** @type {boolean} */
|
|
38
77
|
$pristine: boolean;
|
|
78
|
+
/** @type {boolean} */
|
|
39
79
|
$dirty: boolean;
|
|
80
|
+
/** @type {boolean} */
|
|
40
81
|
$valid: boolean;
|
|
82
|
+
/** @type {boolean} */
|
|
41
83
|
$invalid: boolean;
|
|
42
84
|
$error: {};
|
|
43
85
|
$$success: {};
|
|
@@ -48,7 +90,7 @@ export class NgModelController {
|
|
|
48
90
|
$getControls: () => any;
|
|
49
91
|
$$renameControl: (control: any, name: any) => void;
|
|
50
92
|
$removeControl: () => void;
|
|
51
|
-
$setValidity: () =>
|
|
93
|
+
$setValidity: (...any: any) => any;
|
|
52
94
|
$setDirty: () => void;
|
|
53
95
|
$setPristine: () => void;
|
|
54
96
|
$setSubmitted: () => void;
|
|
@@ -62,26 +104,52 @@ export class NgModelController {
|
|
|
62
104
|
createChild(options: ModelOptionsConfig): any;
|
|
63
105
|
};
|
|
64
106
|
$$updateEvents: string;
|
|
65
|
-
$$updateEventHandler: any;
|
|
66
|
-
$$parsedNgModel:
|
|
67
|
-
$$parsedNgModelAssign: any;
|
|
68
|
-
|
|
69
|
-
$$
|
|
107
|
+
$$updateEventHandler(ev: any): void;
|
|
108
|
+
$$parsedNgModel: import("../../core/parser/parse").CompiledExpression;
|
|
109
|
+
$$parsedNgModelAssign: (arg0: any, arg1: any) => any;
|
|
110
|
+
/** @type {import("../../core/parser/parse").CompiledExpression|((Scope) => any)} */
|
|
111
|
+
$$ngModelGet: import("../../core/parser/parse").CompiledExpression | ((Scope: any) => any);
|
|
112
|
+
$$ngModelSet: (arg0: any, arg1: any) => any;
|
|
70
113
|
$$pendingDebounce: any;
|
|
71
114
|
$$parserValid: boolean;
|
|
72
115
|
$$parserName: string;
|
|
116
|
+
/** @type {number} */
|
|
73
117
|
$$currentValidationRunId: number;
|
|
74
|
-
$$scope:
|
|
75
|
-
$$rootScope:
|
|
76
|
-
$$attr:
|
|
77
|
-
$$element:
|
|
118
|
+
$$scope: import("../../core/scope/scope").Scope;
|
|
119
|
+
$$rootScope: import("../../core/scope/scope").Scope;
|
|
120
|
+
$$attr: import("../../core/compile/attributes").Attributes;
|
|
121
|
+
$$element: import("../../shared/jqlite/jqlite").JQLite;
|
|
78
122
|
$$animate: any;
|
|
79
123
|
$$timeout: any;
|
|
80
|
-
$$parse:
|
|
81
|
-
$$q: any
|
|
124
|
+
$$parse: import("../../core/parser/parse").ParseService;
|
|
125
|
+
$$q: import("../../core/q/q").QPromise<any>;
|
|
82
126
|
$$exceptionHandler: import("../../core/exception-handler").ErrorHandler;
|
|
127
|
+
$$hasNativeValidators: boolean;
|
|
128
|
+
set(object: any, property: any): void;
|
|
129
|
+
unset(object: any, property: any): void;
|
|
130
|
+
$setValidity(validationErrorKey: any, state: any): void;
|
|
83
131
|
$$initGetterSetters(): void;
|
|
84
|
-
|
|
132
|
+
/**
|
|
133
|
+
* @ngdoc method
|
|
134
|
+
* @name ngModel.NgModelController#$render
|
|
135
|
+
*
|
|
136
|
+
* @description
|
|
137
|
+
* Called when the view needs to be updated. It is expected that the user of the ng-model
|
|
138
|
+
* directive will implement this method.
|
|
139
|
+
*
|
|
140
|
+
* The `$render()` method is invoked in the following situations:
|
|
141
|
+
*
|
|
142
|
+
* * `$rollbackViewValue()` is called. If we are rolling back the view value to the last
|
|
143
|
+
* committed value then `$render()` is called to update the input control.
|
|
144
|
+
* * The value referenced by `ng-model` is changed programmatically and both the `$modelValue` and
|
|
145
|
+
* the `$viewValue` are different from last time.
|
|
146
|
+
*
|
|
147
|
+
* Since `ng-model` does not do a deep watch, `$render()` is only invoked if the values of
|
|
148
|
+
* `$modelValue` and `$viewValue` are actually different from their previous values. If `$modelValue`
|
|
149
|
+
* or `$viewValue` are objects (rather than a string or number) then `$render()` will not be
|
|
150
|
+
* invoked if you only change a property on the objects.
|
|
151
|
+
*/
|
|
152
|
+
$render(): void;
|
|
85
153
|
/**
|
|
86
154
|
* @ngdoc method
|
|
87
155
|
* @name ngModel.NgModelController#$isEmpty
|
|
@@ -256,10 +324,6 @@ export class NgModelController {
|
|
|
256
324
|
$validate(): void;
|
|
257
325
|
$$runValidators(modelValue: any, viewValue: any, doneCallback: any): void;
|
|
258
326
|
/**
|
|
259
|
-
* @ngdoc method
|
|
260
|
-
* @name ngModel.NgModelController#$commitViewValue
|
|
261
|
-
*
|
|
262
|
-
* @description
|
|
263
327
|
* Commit a pending update to the `$modelValue`.
|
|
264
328
|
*
|
|
265
329
|
* Updates may be pending by a debounced event or because the input is waiting for a some future
|
|
@@ -468,212 +532,10 @@ export class NgModelController {
|
|
|
468
532
|
/**
|
|
469
533
|
* This method is called internally to run the $formatters on the $modelValue
|
|
470
534
|
*/
|
|
471
|
-
$$format():
|
|
535
|
+
$$format(): any;
|
|
472
536
|
/**
|
|
473
537
|
* This method is called internally when the bound scope value changes.
|
|
474
538
|
*/
|
|
475
539
|
$$setModelValue(modelValue: any): void;
|
|
476
540
|
$$setUpdateOnEvents(): void;
|
|
477
541
|
}
|
|
478
|
-
export namespace NgModelController {
|
|
479
|
-
let $inject: string[];
|
|
480
|
-
}
|
|
481
|
-
export const ngModelMinErr: (arg0: string, ...arg1: any[]) => Error;
|
|
482
|
-
/**
|
|
483
|
-
* @ngdoc directive
|
|
484
|
-
* @name ngModel
|
|
485
|
-
* @restrict A
|
|
486
|
-
* @priority 1
|
|
487
|
-
* @param {string} ngModel assignable {@link guide/expression Expression} to bind to.
|
|
488
|
-
*
|
|
489
|
-
* @description
|
|
490
|
-
* The `ngModel` directive binds an `input`,`select`, `textarea` (or custom form control) to a
|
|
491
|
-
* property on the scope using {@link ngModel.NgModelController NgModelController},
|
|
492
|
-
* which is created and exposed by this directive.
|
|
493
|
-
*
|
|
494
|
-
* `ngModel` is responsible for:
|
|
495
|
-
*
|
|
496
|
-
* - Binding the view into the model, which other directives such as `input`, `textarea` or `select`
|
|
497
|
-
* require.
|
|
498
|
-
* - Providing validation behavior (i.e. required, number, email, url).
|
|
499
|
-
* - Keeping the state of the control (valid/invalid, dirty/pristine, touched/untouched, validation errors).
|
|
500
|
-
* - Setting related css classes on the element (`ng-valid`, `ng-invalid`, `ng-dirty`, `ng-pristine`, `ng-touched`,
|
|
501
|
-
* `ng-untouched`, `ng-empty`, `ng-not-empty`) including animations.
|
|
502
|
-
* - Registering the control with its parent {@link ng.directive:form form}.
|
|
503
|
-
*
|
|
504
|
-
* Note: `ngModel` will try to bind to the property given by evaluating the expression on the
|
|
505
|
-
* current scope. If the property doesn't already exist on this scope, it will be created
|
|
506
|
-
* implicitly and added to the scope.
|
|
507
|
-
*
|
|
508
|
-
* For best practices on using `ngModel`, see:
|
|
509
|
-
*
|
|
510
|
-
* - [Understanding Scopes](https://github.com/angular/angular.js/wiki/Understanding-Scopes)
|
|
511
|
-
*
|
|
512
|
-
* For basic examples, how to use `ngModel`, see:
|
|
513
|
-
*
|
|
514
|
-
* - {@link ng.directive:input input}
|
|
515
|
-
* - {@link input[text] text}
|
|
516
|
-
* - {@link input[checkbox] checkbox}
|
|
517
|
-
* - {@link input[radio] radio}
|
|
518
|
-
* - {@link input[number] number}
|
|
519
|
-
* - {@link input[email] email}
|
|
520
|
-
* - {@link input[url] url}
|
|
521
|
-
* - {@link input[date] date}
|
|
522
|
-
* - {@link input[datetime-local] datetime-local}
|
|
523
|
-
* - {@link input[time] time}
|
|
524
|
-
* - {@link input[month] month}
|
|
525
|
-
* - {@link input[week] week}
|
|
526
|
-
* - {@link ng.directive:select select}
|
|
527
|
-
* - {@link ng.directive:textarea textarea}
|
|
528
|
-
*
|
|
529
|
-
* ## Complex Models (objects or collections)
|
|
530
|
-
*
|
|
531
|
-
* By default, `ngModel` watches the model by reference, not value. This is important to know when
|
|
532
|
-
* binding inputs to models that are objects (e.g. `Date`) or collections (e.g. arrays). If only properties of the
|
|
533
|
-
* object or collection change, `ngModel` will not be notified and so the input will not be re-rendered.
|
|
534
|
-
*
|
|
535
|
-
* The model must be assigned an entirely new object or collection before a re-rendering will occur.
|
|
536
|
-
*
|
|
537
|
-
* Some directives have options that will cause them to use a custom `$watchCollection` on the model expression
|
|
538
|
-
* - for example, `ngOptions` will do so when a `track by` clause is included in the comprehension expression or
|
|
539
|
-
* if the select is given the `multiple` attribute.
|
|
540
|
-
*
|
|
541
|
-
* The `$watchCollection()` method only does a shallow comparison, meaning that changing properties deeper than the
|
|
542
|
-
* first level of the object (or only changing the properties of an item in the collection if it's an array) will still
|
|
543
|
-
* not trigger a re-rendering of the model.
|
|
544
|
-
*
|
|
545
|
-
* ## CSS classes
|
|
546
|
-
* The following CSS classes are added and removed on the associated input/select/textarea element
|
|
547
|
-
* depending on the validity of the model.
|
|
548
|
-
*
|
|
549
|
-
* - `ng-valid`: the model is valid
|
|
550
|
-
* - `ng-invalid`: the model is invalid
|
|
551
|
-
* - `ng-valid-[key]`: for each valid key added by `$setValidity`
|
|
552
|
-
* - `ng-invalid-[key]`: for each invalid key added by `$setValidity`
|
|
553
|
-
* - `ng-pristine`: the control hasn't been interacted with yet
|
|
554
|
-
* - `ng-dirty`: the control has been interacted with
|
|
555
|
-
* - `ng-touched`: the control has been blurred
|
|
556
|
-
* - `ng-untouched`: the control hasn't been blurred
|
|
557
|
-
* - `ng-pending`: any `$asyncValidators` are unfulfilled
|
|
558
|
-
* - `ng-empty`: the view does not contain a value or the value is deemed "empty", as defined
|
|
559
|
-
* by the {@link ngModel.NgModelController#$isEmpty} method
|
|
560
|
-
* - `ng-not-empty`: the view contains a non-empty value
|
|
561
|
-
*
|
|
562
|
-
* Keep in mind that ngAnimate can detect each of these classes when added and removed.
|
|
563
|
-
*
|
|
564
|
-
* @animations
|
|
565
|
-
* Animations within models are triggered when any of the associated CSS classes are added and removed
|
|
566
|
-
* on the input element which is attached to the model. These classes include: `.ng-pristine`, `.ng-dirty`,
|
|
567
|
-
* `.ng-invalid` and `.ng-valid` as well as any other validations that are performed on the model itself.
|
|
568
|
-
* The animations that are triggered within ngModel are similar to how they work in ngClass and
|
|
569
|
-
* animations can be hooked into using CSS transitions, keyframes as well as JS animations.
|
|
570
|
-
*
|
|
571
|
-
* The following example shows a simple way to utilize CSS transitions to style an input element
|
|
572
|
-
* that has been rendered as invalid after it has been validated:
|
|
573
|
-
*
|
|
574
|
-
* <pre>
|
|
575
|
-
* //be sure to include ngAnimate as a module to hook into more
|
|
576
|
-
* //advanced animations
|
|
577
|
-
* .my-input {
|
|
578
|
-
* transition:0.5s linear all;
|
|
579
|
-
* background: white;
|
|
580
|
-
* }
|
|
581
|
-
* .my-input.ng-invalid {
|
|
582
|
-
* background: red;
|
|
583
|
-
* color:white;
|
|
584
|
-
* }
|
|
585
|
-
* </pre>
|
|
586
|
-
*
|
|
587
|
-
* @example
|
|
588
|
-
* ### Basic Usage
|
|
589
|
-
* <example deps="angular-animate.js" animations="true" fixBase="true" module="inputExample" name="ng-model">
|
|
590
|
-
<file name="index.html">
|
|
591
|
-
<script>
|
|
592
|
-
angular.module('inputExample', [])
|
|
593
|
-
.controller('ExampleController', ['$scope', function($scope) {
|
|
594
|
-
$scope.val = '1';
|
|
595
|
-
}]);
|
|
596
|
-
</script>
|
|
597
|
-
<style>
|
|
598
|
-
.my-input {
|
|
599
|
-
transition:all linear 0.5s;
|
|
600
|
-
background: transparent;
|
|
601
|
-
}
|
|
602
|
-
.my-input.ng-invalid {
|
|
603
|
-
color:white;
|
|
604
|
-
background: red;
|
|
605
|
-
}
|
|
606
|
-
</style>
|
|
607
|
-
<p id="inputDescription">
|
|
608
|
-
Update input to see transitions when valid/invalid.
|
|
609
|
-
Integer is a valid value.
|
|
610
|
-
</p>
|
|
611
|
-
<form name="testForm" ng-controller="ExampleController">
|
|
612
|
-
<input ng-model="val" ng-pattern="/^\d+$/" name="anim" class="my-input"
|
|
613
|
-
aria-describedby="inputDescription" />
|
|
614
|
-
</form>
|
|
615
|
-
</file>
|
|
616
|
-
* </example>
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
619
|
-
* ### Binding to a getter/setter
|
|
620
|
-
*
|
|
621
|
-
* Sometimes it's helpful to bind `ngModel` to a getter/setter function. A getter/setter is a
|
|
622
|
-
* function that returns a representation of the model when called with zero arguments, and sets
|
|
623
|
-
* the internal state of a model when called with an argument. It's sometimes useful to use this
|
|
624
|
-
* for models that have an internal representation that's different from what the model exposes
|
|
625
|
-
* to the view.
|
|
626
|
-
*
|
|
627
|
-
* <div class="alert alert-success">
|
|
628
|
-
* **Best Practice:** It's best to keep getters fast because AngularJS is likely to call them more
|
|
629
|
-
* frequently than other parts of your code.
|
|
630
|
-
* </div>
|
|
631
|
-
*
|
|
632
|
-
* You use this behavior by adding `ng-model-options="{ getterSetter: true }"` to an element that
|
|
633
|
-
* has `ng-model` attached to it. You can also add `ng-model-options="{ getterSetter: true }"` to
|
|
634
|
-
* a `<form>`, which will enable this behavior for all `<input>`s within it. See
|
|
635
|
-
* {@link ng.directive:ngModelOptions `ngModelOptions`} for more.
|
|
636
|
-
*
|
|
637
|
-
* The following example shows how to use `ngModel` with a getter/setter:
|
|
638
|
-
*
|
|
639
|
-
* @example
|
|
640
|
-
* <example name="ngModel-getter-setter" module="getterSetterExample">
|
|
641
|
-
<file name="index.html">
|
|
642
|
-
<div ng-controller="ExampleController">
|
|
643
|
-
<form name="userForm">
|
|
644
|
-
<label>Name:
|
|
645
|
-
<input type="text" name="userName"
|
|
646
|
-
ng-model="user.name"
|
|
647
|
-
ng-model-options="{ getterSetter: true }" />
|
|
648
|
-
</label>
|
|
649
|
-
</form>
|
|
650
|
-
<pre>user.name = <span ng-bind="user.name()"></span></pre>
|
|
651
|
-
</div>
|
|
652
|
-
</file>
|
|
653
|
-
<file name="app.js">
|
|
654
|
-
angular.module('getterSetterExample', [])
|
|
655
|
-
.controller('ExampleController', ['$scope', function($scope) {
|
|
656
|
-
let _name = 'Brian';
|
|
657
|
-
$scope.user = {
|
|
658
|
-
name: function(newName) {
|
|
659
|
-
// Note that newName can be undefined for two reasons:
|
|
660
|
-
// 1. Because it is called as a getter and thus called with no arguments
|
|
661
|
-
// 2. Because the property should actually be set to undefined. This happens e.g. if the
|
|
662
|
-
// input is invalid
|
|
663
|
-
return arguments.length ? (_name = newName) : _name;
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
}]);
|
|
667
|
-
</file>
|
|
668
|
-
* </example>
|
|
669
|
-
*/
|
|
670
|
-
export const ngModelDirective: (string | (($rootScope: any) => {
|
|
671
|
-
restrict: string;
|
|
672
|
-
require: string[];
|
|
673
|
-
controller: typeof NgModelController;
|
|
674
|
-
priority: number;
|
|
675
|
-
compile: (element: any) => {
|
|
676
|
-
pre: (scope: any, element: any, attr: any, ctrls: any) => void;
|
|
677
|
-
post: (scope: any, element: any, attr: any, ctrls: any) => void;
|
|
678
|
-
};
|
|
679
|
-
}))[];
|
package/types/shared/common.d.ts
CHANGED
|
@@ -68,7 +68,6 @@ export function createProxyFunctions(source: any, target: any, bind: any, fnName
|
|
|
68
68
|
* @returns {Object} - A new object with `parent` as its prototype and properties from `extra`.
|
|
69
69
|
*/
|
|
70
70
|
export function inherit(parent: any, extra?: any): any;
|
|
71
|
-
export function _inArray(array: any, obj: any): any;
|
|
72
71
|
export function _removeFrom(array: any, obj: any): any;
|
|
73
72
|
/**
|
|
74
73
|
* Applies a set of defaults to an options object. The options object is filtered
|
|
@@ -172,8 +171,6 @@ export const toJson: any;
|
|
|
172
171
|
/** Naive forEach implementation works with Objects or Arrays */
|
|
173
172
|
export function forEach(obj: any, cb: any, _this: any): void;
|
|
174
173
|
export function equals(o1: any, o2: any): any;
|
|
175
|
-
/** Given an array, returns true if the object is found in the array, (using includes) */
|
|
176
|
-
export const inArray: any;
|
|
177
174
|
/**
|
|
178
175
|
* Given an array, and an item, if the item is found in the array, it removes it (in-place).
|
|
179
176
|
* The same array is returned
|
package/types/shared/hof.d.ts
CHANGED
|
@@ -123,7 +123,6 @@ export function prop(name: any): (obj: any) => any;
|
|
|
123
123
|
*/
|
|
124
124
|
export const propEq: any;
|
|
125
125
|
export function parse(name: any): any;
|
|
126
|
-
export function not(fn: any): (...args: any[]) => boolean;
|
|
127
126
|
export function all(fn1: any): (arr: any) => any;
|
|
128
127
|
export function any(fn1: any): (arr: any) => any;
|
|
129
128
|
export function is(ctor: any): (obj: any) => boolean;
|
|
@@ -191,10 +191,10 @@ export function getOrSetCacheData(element: Element, key: string | any, value?: a
|
|
|
191
191
|
*/
|
|
192
192
|
export function removeElement(element: Element, keepData?: boolean): void;
|
|
193
193
|
/**
|
|
194
|
-
* @param {string} elementStr
|
|
194
|
+
* @param {string|JQLite} elementStr
|
|
195
195
|
* @returns {string} Returns the string representation of the element.
|
|
196
196
|
*/
|
|
197
|
-
export function startingTag(elementStr: string): string;
|
|
197
|
+
export function startingTag(elementStr: string | JQLite): string;
|
|
198
198
|
/**
|
|
199
199
|
* Return the DOM siblings between the first and last node in the given array.
|
|
200
200
|
* @param {JQLite|Array} nodes An array-like object
|
package/types/types.d.ts
CHANGED
|
@@ -8,14 +8,16 @@ export type ComponentOptions = any;
|
|
|
8
8
|
export type ControllerConstructor = Function;
|
|
9
9
|
export type OnChangesObject = any;
|
|
10
10
|
export type ChangesObject = any;
|
|
11
|
-
export type Controller =
|
|
11
|
+
export type Controller = {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
12
14
|
export type Attributes = {
|
|
13
15
|
[x: string]: any;
|
|
14
16
|
};
|
|
15
17
|
export type TScope = import("./core/scope/scope").Scope;
|
|
16
18
|
export type TElement = import("./shared/jqlite/jqlite").JQLite;
|
|
17
19
|
export type TAttributes = Attributes;
|
|
18
|
-
export type TController = DirectiveController;
|
|
20
|
+
export type TController = DirectiveController | NgModelController;
|
|
19
21
|
export type DirectiveController = Controller | Controller[] | {
|
|
20
22
|
[key: string]: Controller;
|
|
21
23
|
};
|