@angular/core 12.1.0-next.3 → 12.1.0
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/bundles/core-testing.umd.js +229 -101
- package/bundles/core-testing.umd.js.map +1 -1
- package/bundles/core.umd.js +65 -28
- package/bundles/core.umd.js.map +1 -1
- package/core.d.ts +269 -19
- package/core.metadata.json +1 -1
- package/esm2015/src/application_ref.js +29 -8
- package/esm2015/src/change_detection/differs/iterable_differs.js +1 -1
- package/esm2015/src/debug/debug_node.js +1 -1
- package/esm2015/src/di/injectable.js +1 -1
- package/esm2015/src/di/injector_marker.js +1 -1
- package/esm2015/src/linker/component_factory_resolver.js +4 -1
- package/esm2015/src/linker/element_ref.js +1 -1
- package/esm2015/src/linker/query_list.js +2 -1
- package/esm2015/src/metadata/di.js +1 -1
- package/esm2015/src/metadata/do_boostrap.js +1 -1
- package/esm2015/src/metadata/ng_module.js +1 -1
- package/esm2015/src/metadata/schema.js +5 -1
- package/esm2015/src/render3/definition.js +16 -16
- package/esm2015/src/render3/node_assert.js +1 -1
- package/esm2015/src/util/assert.js +1 -1
- package/esm2015/src/util/decorators.js +1 -1
- package/esm2015/src/util/dom.js +1 -1
- package/esm2015/src/version.js +1 -1
- package/esm2015/src/view/util.js +3 -1
- package/esm2015/testing/src/r3_test_bed.js +84 -7
- package/esm2015/testing/src/test_bed.js +103 -42
- package/esm2015/testing/src/test_bed_common.js +7 -1
- package/esm2015/testing/src/test_hooks.js +45 -0
- package/esm2015/testing/src/testing.js +3 -3
- package/esm2015/testing/src/testing_internal.js +1 -182
- package/fesm2015/core.js +55 -24
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/testing.js +206 -77
- package/fesm2015/testing.js.map +1 -1
- package/package.json +2 -2
- package/schematics/migrations/can-activate-with-redirect-to/util.js +1 -1
- package/schematics/migrations/can-activate-with-redirect-to/util.mjs +1 -1
- package/schematics/migrations/initial-navigation/collector.js +3 -2
- package/schematics/migrations/initial-navigation/collector.mjs +3 -2
- package/schematics/migrations/navigation-extras-omissions/util.js +2 -3
- package/schematics/migrations/navigation-extras-omissions/util.mjs +2 -3
- package/schematics/migrations/relative-link-resolution/collector.js +3 -2
- package/schematics/migrations/relative-link-resolution/collector.mjs +3 -2
- package/schematics/migrations/relative-link-resolution/update_recorder.js +1 -1
- package/schematics/migrations/relative-link-resolution/update_recorder.mjs +1 -1
- package/schematics/migrations/static-queries/strategies/usage_strategy/declaration_usage_visitor.js +2 -2
- package/schematics/migrations/static-queries/strategies/usage_strategy/declaration_usage_visitor.mjs +2 -2
- package/schematics/migrations/xhr-factory/index.js +1 -1
- package/schematics/migrations/xhr-factory/index.mjs +1 -1
- package/schematics/utils/typescript/imports.js +2 -2
- package/schematics/utils/typescript/imports.mjs +2 -2
- package/src/r3_symbols.d.ts +4 -1
- package/testing/testing.d.ts +63 -10
- package/testing/testing.metadata.json +1 -1
- package/testing.d.ts +1 -1
- package/esm2015/testing/src/async_test_completer.js +0 -28
- package/esm2015/testing/src/before_each.js +0 -33
package/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v12.1.0
|
|
2
|
+
* @license Angular v12.1.0
|
|
3
3
|
* (c) 2010-2021 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -411,20 +411,41 @@ export declare class ApplicationRef {
|
|
|
411
411
|
*/
|
|
412
412
|
readonly isStable: Observable<boolean>;
|
|
413
413
|
/**
|
|
414
|
-
* Bootstrap a
|
|
414
|
+
* Bootstrap a component onto the element identified by its selector or, optionally, to a
|
|
415
|
+
* specified element.
|
|
415
416
|
*
|
|
416
417
|
* @usageNotes
|
|
417
418
|
* ### Bootstrap process
|
|
418
419
|
*
|
|
419
|
-
* When bootstrapping a
|
|
420
|
-
*
|
|
421
|
-
*
|
|
420
|
+
* When bootstrapping a component, Angular mounts it onto a target DOM element
|
|
421
|
+
* and kicks off automatic change detection. The target DOM element can be
|
|
422
|
+
* provided using the `rootSelectorOrNode` argument.
|
|
422
423
|
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
424
|
+
* If the target DOM element is not provided, Angular tries to find one on a page
|
|
425
|
+
* using the `selector` of the component that is being bootstrapped
|
|
426
|
+
* (first matched element is used).
|
|
425
427
|
*
|
|
426
428
|
* ### Example
|
|
427
|
-
*
|
|
429
|
+
*
|
|
430
|
+
* Generally, we define the component to bootstrap in the `bootstrap` array of `NgModule`,
|
|
431
|
+
* but it requires us to know the component while writing the application code.
|
|
432
|
+
*
|
|
433
|
+
* Imagine a situation where we have to wait for an API call to decide about the component to
|
|
434
|
+
* bootstrap. We can use the `ngDoBootstrap` hook of the `NgModule` and call this method to
|
|
435
|
+
* dynamically bootstrap a component.
|
|
436
|
+
*
|
|
437
|
+
* {@example core/ts/platform/platform.ts region='componentSelector'}
|
|
438
|
+
*
|
|
439
|
+
* Optionally, a component can be mounted onto a DOM element that does not match the
|
|
440
|
+
* selector of the bootstrapped component.
|
|
441
|
+
*
|
|
442
|
+
* In the following example, we are providing a CSS selector to match the target element.
|
|
443
|
+
*
|
|
444
|
+
* {@example core/ts/platform/platform.ts region='cssSelector'}
|
|
445
|
+
*
|
|
446
|
+
* While in this example, we are providing reference to a DOM node.
|
|
447
|
+
*
|
|
448
|
+
* {@example core/ts/platform/platform.ts region='domNode'}
|
|
428
449
|
*/
|
|
429
450
|
bootstrap<C>(componentOrFactory: ComponentFactory<C> | Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
|
|
430
451
|
/**
|
|
@@ -1153,6 +1174,9 @@ export { ComponentFactory as ɵComponentFactory }
|
|
|
1153
1174
|
* then use the factory's `create()` method to create a component of that type.
|
|
1154
1175
|
*
|
|
1155
1176
|
* @see [Dynamic Components](guide/dynamic-component-loader)
|
|
1177
|
+
* @see [Usage Example](guide/dynamic-component-loader#resolving-components)
|
|
1178
|
+
* @see <live-example name="dynamic-component-loader" noDownload></live-example>
|
|
1179
|
+
of the code in this cookbook
|
|
1156
1180
|
* @publicApi
|
|
1157
1181
|
*/
|
|
1158
1182
|
export declare abstract class ComponentFactoryResolver {
|
|
@@ -1318,6 +1342,24 @@ export declare interface ContentChildDecorator {
|
|
|
1318
1342
|
* * **static** - True to resolve query results before change detection runs,
|
|
1319
1343
|
* false to resolve after change detection. Defaults to false.
|
|
1320
1344
|
*
|
|
1345
|
+
* The following selectors are supported.
|
|
1346
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
1347
|
+
* * A template reference variable as a string (e.g. query `<my-component #cmp></my-component>`
|
|
1348
|
+
* with `@ContentChild('cmp')`)
|
|
1349
|
+
* * Any provider defined in the child component tree of the current component (e.g.
|
|
1350
|
+
* `@ContentChild(SomeService) someService: SomeService`)
|
|
1351
|
+
* * Any provider defined through a string token (e.g. `@ContentChild('someToken') someTokenVal:
|
|
1352
|
+
* any`)
|
|
1353
|
+
* * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with `@ContentChild(TemplateRef)
|
|
1354
|
+
* template;`)
|
|
1355
|
+
*
|
|
1356
|
+
* The following values are supported by `read`:
|
|
1357
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
1358
|
+
* * Any provider defined on the injector of the component that is matched by the `selector` of
|
|
1359
|
+
* this query
|
|
1360
|
+
* * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
|
|
1361
|
+
* * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
|
|
1362
|
+
*
|
|
1321
1363
|
* @usageNotes
|
|
1322
1364
|
*
|
|
1323
1365
|
* {@example core/di/ts/contentChild/content_child_howto.ts region='HowTo'}
|
|
@@ -1387,6 +1429,27 @@ export declare interface ContentChildrenDecorator {
|
|
|
1387
1429
|
* removed in future versions of Angular.
|
|
1388
1430
|
* * **read** - Used to read a different token from the queried elements.
|
|
1389
1431
|
*
|
|
1432
|
+
* The following selectors are supported.
|
|
1433
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
1434
|
+
* * A template reference variable as a string (e.g. query `<my-component #cmp></my-component>`
|
|
1435
|
+
* with `@ContentChildren('cmp')`)
|
|
1436
|
+
* * Any provider defined in the child component tree of the current component (e.g.
|
|
1437
|
+
* `@ContentChildren(SomeService) someService: SomeService`)
|
|
1438
|
+
* * Any provider defined through a string token (e.g. `@ContentChildren('someToken')
|
|
1439
|
+
* someTokenVal: any`)
|
|
1440
|
+
* * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with
|
|
1441
|
+
* `@ContentChildren(TemplateRef) template;`)
|
|
1442
|
+
*
|
|
1443
|
+
* In addition, multiple string selectors can be separated with a comma (e.g.
|
|
1444
|
+
* `@ContentChildren('cmp1,cmp2')`)
|
|
1445
|
+
*
|
|
1446
|
+
* The following values are supported by `read`:
|
|
1447
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
1448
|
+
* * Any provider defined on the injector of the component that is matched by the `selector` of
|
|
1449
|
+
* this query
|
|
1450
|
+
* * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
|
|
1451
|
+
* * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
|
|
1452
|
+
*
|
|
1390
1453
|
* @usageNotes
|
|
1391
1454
|
*
|
|
1392
1455
|
* Here is a simple demonstration of how the `ContentChildren` decorator can be used.
|
|
@@ -1560,27 +1623,98 @@ export declare const CUSTOM_ELEMENTS_SCHEMA: SchemaMetadata;
|
|
|
1560
1623
|
|
|
1561
1624
|
/**
|
|
1562
1625
|
* @publicApi
|
|
1626
|
+
*
|
|
1627
|
+
* @see [Component testing scenarios](guide/testing-components-scenarios)
|
|
1628
|
+
* @see [Basics of testing components](guide/testing-components-basics)
|
|
1629
|
+
* @see [Testing utility APIs](guide/testing-utility-apis)
|
|
1563
1630
|
*/
|
|
1564
1631
|
export declare interface DebugElement extends DebugNode {
|
|
1632
|
+
/**
|
|
1633
|
+
* The element tag name, if it is an element.
|
|
1634
|
+
*/
|
|
1565
1635
|
readonly name: string;
|
|
1636
|
+
/**
|
|
1637
|
+
* A map of property names to property values for an element.
|
|
1638
|
+
*
|
|
1639
|
+
* This map includes:
|
|
1640
|
+
* - Regular property bindings (e.g. `[id]="id"`)
|
|
1641
|
+
* - Host property bindings (e.g. `host: { '[id]': "id" }`)
|
|
1642
|
+
* - Interpolated property bindings (e.g. `id="{{ value }}")
|
|
1643
|
+
*
|
|
1644
|
+
* It does not include:
|
|
1645
|
+
* - input property bindings (e.g. `[myCustomInput]="value"`)
|
|
1646
|
+
* - attribute bindings (e.g. `[attr.role]="menu"`)
|
|
1647
|
+
*/
|
|
1566
1648
|
readonly properties: {
|
|
1567
1649
|
[key: string]: any;
|
|
1568
1650
|
};
|
|
1651
|
+
/**
|
|
1652
|
+
* A map of attribute names to attribute values for an element.
|
|
1653
|
+
*/
|
|
1569
1654
|
readonly attributes: {
|
|
1570
1655
|
[key: string]: string | null;
|
|
1571
1656
|
};
|
|
1657
|
+
/**
|
|
1658
|
+
* A map containing the class names on the element as keys.
|
|
1659
|
+
*
|
|
1660
|
+
* This map is derived from the `className` property of the DOM element.
|
|
1661
|
+
*
|
|
1662
|
+
* Note: The values of this object will always be `true`. The class key will not appear in the KV
|
|
1663
|
+
* object if it does not exist on the element.
|
|
1664
|
+
*
|
|
1665
|
+
* @see [Element.className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className)
|
|
1666
|
+
*/
|
|
1572
1667
|
readonly classes: {
|
|
1573
1668
|
[key: string]: boolean;
|
|
1574
1669
|
};
|
|
1670
|
+
/**
|
|
1671
|
+
* The inline styles of the DOM element.
|
|
1672
|
+
*
|
|
1673
|
+
* Will be `null` if there is no `style` property on the underlying DOM element.
|
|
1674
|
+
*
|
|
1675
|
+
* @see [ElementCSSInlineStyle](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style)
|
|
1676
|
+
*/
|
|
1575
1677
|
readonly styles: {
|
|
1576
1678
|
[key: string]: string | null;
|
|
1577
1679
|
};
|
|
1680
|
+
/**
|
|
1681
|
+
* The `childNodes` of the DOM element as a `DebugNode` array.
|
|
1682
|
+
*
|
|
1683
|
+
* @see [Node.childNodes](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
|
|
1684
|
+
*/
|
|
1578
1685
|
readonly childNodes: DebugNode[];
|
|
1686
|
+
/**
|
|
1687
|
+
* The underlying DOM element at the root of the component.
|
|
1688
|
+
*/
|
|
1579
1689
|
readonly nativeElement: any;
|
|
1690
|
+
/**
|
|
1691
|
+
* The immediate `DebugElement` children. Walk the tree by descending through `children`.
|
|
1692
|
+
*/
|
|
1580
1693
|
readonly children: DebugElement[];
|
|
1694
|
+
/**
|
|
1695
|
+
* @returns the first `DebugElement` that matches the predicate at any depth in the subtree.
|
|
1696
|
+
*/
|
|
1581
1697
|
query(predicate: Predicate<DebugElement>): DebugElement;
|
|
1698
|
+
/**
|
|
1699
|
+
* @returns All `DebugElement` matches for the predicate at any depth in the subtree.
|
|
1700
|
+
*/
|
|
1582
1701
|
queryAll(predicate: Predicate<DebugElement>): DebugElement[];
|
|
1702
|
+
/**
|
|
1703
|
+
* @returns All `DebugNode` matches for the predicate at any depth in the subtree.
|
|
1704
|
+
*/
|
|
1583
1705
|
queryAllNodes(predicate: Predicate<DebugNode>): DebugNode[];
|
|
1706
|
+
/**
|
|
1707
|
+
* Triggers the event by its name if there is a corresponding listener in the element's
|
|
1708
|
+
* `listeners` collection.
|
|
1709
|
+
*
|
|
1710
|
+
* If the event lacks a listener or there's some other problem, consider
|
|
1711
|
+
* calling `nativeElement.dispatchEvent(eventObject)`.
|
|
1712
|
+
*
|
|
1713
|
+
* @param eventName The name of the event to trigger
|
|
1714
|
+
* @param eventObj The _event object_ expected by the handler
|
|
1715
|
+
*
|
|
1716
|
+
* @see [Testing components scenarios](guide/testing-components-scenarios#trigger-event-handler)
|
|
1717
|
+
*/
|
|
1584
1718
|
triggerEventHandler(eventName: string, eventObj: any): void;
|
|
1585
1719
|
}
|
|
1586
1720
|
|
|
@@ -1640,15 +1774,47 @@ export declare class DebugEventListener {
|
|
|
1640
1774
|
* @publicApi
|
|
1641
1775
|
*/
|
|
1642
1776
|
export declare interface DebugNode {
|
|
1777
|
+
/**
|
|
1778
|
+
* The callbacks attached to the component's @Output properties and/or the element's event
|
|
1779
|
+
* properties.
|
|
1780
|
+
*/
|
|
1643
1781
|
readonly listeners: DebugEventListener[];
|
|
1782
|
+
/**
|
|
1783
|
+
* The `DebugElement` parent. Will be `null` if this is the root element.
|
|
1784
|
+
*/
|
|
1644
1785
|
readonly parent: DebugElement | null;
|
|
1786
|
+
/**
|
|
1787
|
+
* The underlying DOM node.
|
|
1788
|
+
*/
|
|
1645
1789
|
readonly nativeNode: any;
|
|
1790
|
+
/**
|
|
1791
|
+
* The host dependency injector. For example, the root element's component instance injector.
|
|
1792
|
+
*/
|
|
1646
1793
|
readonly injector: Injector;
|
|
1794
|
+
/**
|
|
1795
|
+
* The element's own component instance, if it has one.
|
|
1796
|
+
*/
|
|
1647
1797
|
readonly componentInstance: any;
|
|
1798
|
+
/**
|
|
1799
|
+
* An object that provides parent context for this element. Often an ancestor component instance
|
|
1800
|
+
* that governs this element.
|
|
1801
|
+
*
|
|
1802
|
+
* When an element is repeated within *ngFor, the context is an `NgForOf` whose `$implicit`
|
|
1803
|
+
* property is the value of the row instance value. For example, the `hero` in `*ngFor="let hero
|
|
1804
|
+
* of heroes"`.
|
|
1805
|
+
*/
|
|
1648
1806
|
readonly context: any;
|
|
1807
|
+
/**
|
|
1808
|
+
* Dictionary of objects associated with template local variables (e.g. #foo), keyed by the local
|
|
1809
|
+
* variable name.
|
|
1810
|
+
*/
|
|
1649
1811
|
readonly references: {
|
|
1650
1812
|
[key: string]: any;
|
|
1651
1813
|
};
|
|
1814
|
+
/**
|
|
1815
|
+
* This component's injector lookup tokens. Includes the component itself plus the tokens that the
|
|
1816
|
+
* component lists in its providers metadata.
|
|
1817
|
+
*/
|
|
1652
1818
|
readonly providerTokens: any[];
|
|
1653
1819
|
}
|
|
1654
1820
|
|
|
@@ -2162,14 +2328,17 @@ declare interface DisposableFn {
|
|
|
2162
2328
|
|
|
2163
2329
|
/**
|
|
2164
2330
|
* @description
|
|
2165
|
-
* Hook for manual bootstrapping of the application instead of using bootstrap array in @NgModule
|
|
2166
|
-
* annotation.
|
|
2331
|
+
* Hook for manual bootstrapping of the application instead of using `bootstrap` array in @NgModule
|
|
2332
|
+
* annotation. This hook is invoked only when the `bootstrap` array is empty or not provided.
|
|
2167
2333
|
*
|
|
2168
2334
|
* Reference to the current application is provided as a parameter.
|
|
2169
2335
|
*
|
|
2170
2336
|
* See ["Bootstrapping"](guide/bootstrapping) and ["Entry components"](guide/entry-components).
|
|
2171
2337
|
*
|
|
2172
2338
|
* @usageNotes
|
|
2339
|
+
* The example below uses `ApplicationRef.bootstrap()` to render the
|
|
2340
|
+
* `AppComponent` on the page.
|
|
2341
|
+
*
|
|
2173
2342
|
* ```typescript
|
|
2174
2343
|
* class AppModule implements DoBootstrap {
|
|
2175
2344
|
* ngDoBootstrap(appRef: ApplicationRef) {
|
|
@@ -3256,9 +3425,15 @@ export declare const inject: typeof ɵɵinject;
|
|
|
3256
3425
|
*/
|
|
3257
3426
|
export declare interface Injectable {
|
|
3258
3427
|
/**
|
|
3259
|
-
* Determines which injectors will provide the injectable
|
|
3260
|
-
*
|
|
3261
|
-
*
|
|
3428
|
+
* Determines which injectors will provide the injectable.
|
|
3429
|
+
*
|
|
3430
|
+
* - `Type<any>` - associates the injectable with an `@NgModule` or other `InjectorType`,
|
|
3431
|
+
* - 'null' : Equivalent to `undefined`. The injectable is not provided in any scope automatically
|
|
3432
|
+
* and must be added to a `providers` array of an [@NgModule](api/core/NgModule#providers),
|
|
3433
|
+
* [@Component](api/core/Directive#providers) or [@Directive](api/core/Directive#providers).
|
|
3434
|
+
*
|
|
3435
|
+
* The following options specify that this injectable should be provided in one of the following
|
|
3436
|
+
* injectors:
|
|
3262
3437
|
* - 'root' : The application-level injector in most apps.
|
|
3263
3438
|
* - 'platform' : A special singleton platform injector shared by all
|
|
3264
3439
|
* applications on the page.
|
|
@@ -4507,7 +4682,10 @@ export declare interface NgModule {
|
|
|
4507
4682
|
* using one of the imperative techniques, such as `ViewContainerRef.createComponent()`.
|
|
4508
4683
|
*
|
|
4509
4684
|
* @see [Entry Components](guide/entry-components)
|
|
4510
|
-
* @deprecated
|
|
4685
|
+
* @deprecated
|
|
4686
|
+
* Since 9.0.0. With Ivy, this property is no longer necessary.
|
|
4687
|
+
* (You may need to keep these if building a library that will be consumed by a View Engine
|
|
4688
|
+
* application.)
|
|
4511
4689
|
*/
|
|
4512
4690
|
entryComponents?: Array<Type<any> | any[]>;
|
|
4513
4691
|
/**
|
|
@@ -4800,6 +4978,10 @@ export declare class NgZone {
|
|
|
4800
4978
|
/**
|
|
4801
4979
|
* Defines a schema that allows any property on any element.
|
|
4802
4980
|
*
|
|
4981
|
+
* This schema allows you to ignore the errors related to any unknown elements or properties in a
|
|
4982
|
+
* template. The usage of this schema is generally discouraged because it prevents useful validation
|
|
4983
|
+
* and may hide real errors in your template. Consider using the `CUSTOM_ELEMENTS_SCHEMA` instead.
|
|
4984
|
+
*
|
|
4803
4985
|
* @publicApi
|
|
4804
4986
|
*/
|
|
4805
4987
|
export declare const NO_ERRORS_SCHEMA: SchemaMetadata;
|
|
@@ -7837,15 +8019,55 @@ declare interface TQueryMetadata {
|
|
|
7837
8019
|
}
|
|
7838
8020
|
|
|
7839
8021
|
/**
|
|
7840
|
-
*
|
|
7841
|
-
*
|
|
7842
|
-
*
|
|
7843
|
-
*
|
|
8022
|
+
* A function optionally passed into the `NgForOf` directive to customize how `NgForOf` uniquely
|
|
8023
|
+
* identifies items in an iterable.
|
|
8024
|
+
*
|
|
8025
|
+
* `NgForOf` needs to uniquely identify items in the iterable to correctly perform DOM updates
|
|
8026
|
+
* when items in the iterable are reordered, new items are added, or existing items are removed.
|
|
8027
|
+
*
|
|
8028
|
+
*
|
|
8029
|
+
* In all of these scenarios it is usually desirable to only update the DOM elements associated
|
|
8030
|
+
* with the items affected by the change. This behavior is important to:
|
|
8031
|
+
*
|
|
8032
|
+
* - preserve any DOM-specific UI state (like cursor position, focus, text selection) when the
|
|
8033
|
+
* iterable is modified
|
|
8034
|
+
* - enable animation of item addition, removal, and iterable reordering
|
|
8035
|
+
* - preserve the value of the `<select>` element when nested `<option>` elements are dynamically
|
|
8036
|
+
* populated using `NgForOf` and the bound iterable is updated
|
|
8037
|
+
*
|
|
8038
|
+
* A common use for custom `trackBy` functions is when the model that `NgForOf` iterates over
|
|
8039
|
+
* contains a property with a unique identifier. For example, given a model:
|
|
8040
|
+
*
|
|
8041
|
+
* ```ts
|
|
8042
|
+
* class User {
|
|
8043
|
+
* id: number;
|
|
8044
|
+
* name: string;
|
|
8045
|
+
* ...
|
|
8046
|
+
* }
|
|
8047
|
+
* ```
|
|
8048
|
+
* a custom `trackBy` function could look like the following:
|
|
8049
|
+
* ```ts
|
|
8050
|
+
* function userTrackBy(index, user) {
|
|
8051
|
+
* return user.id;
|
|
8052
|
+
* }
|
|
8053
|
+
* ```
|
|
8054
|
+
*
|
|
8055
|
+
* A custom `trackBy` function must have several properties:
|
|
7844
8056
|
*
|
|
8057
|
+
* - be [idempotent](https://en.wikipedia.org/wiki/Idempotence) (be without side effects, and always
|
|
8058
|
+
* return the same value for a given input)
|
|
8059
|
+
* - return unique value for all unique inputs
|
|
8060
|
+
* - be fast
|
|
8061
|
+
*
|
|
8062
|
+
* @see [`NgForOf#ngForTrackBy`](api/common/NgForOf#ngForTrackBy)
|
|
7845
8063
|
* @publicApi
|
|
7846
8064
|
*/
|
|
7847
8065
|
export declare interface TrackByFunction<T> {
|
|
7848
|
-
|
|
8066
|
+
/**
|
|
8067
|
+
* @param index The index of the item within the iterable.
|
|
8068
|
+
* @param item The item in the iterable.
|
|
8069
|
+
*/
|
|
8070
|
+
<U extends T>(index: number, item: U): any;
|
|
7849
8071
|
}
|
|
7850
8072
|
|
|
7851
8073
|
/**
|
|
@@ -8488,6 +8710,13 @@ export declare interface ViewChildDecorator {
|
|
|
8488
8710
|
* * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with `@ViewChild(TemplateRef)
|
|
8489
8711
|
* template;`)
|
|
8490
8712
|
*
|
|
8713
|
+
* The following values are supported by `read`:
|
|
8714
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
8715
|
+
* * Any provider defined on the injector of the component that is matched by the `selector` of
|
|
8716
|
+
* this query
|
|
8717
|
+
* * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
|
|
8718
|
+
* * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
|
|
8719
|
+
*
|
|
8491
8720
|
* @usageNotes
|
|
8492
8721
|
*
|
|
8493
8722
|
* {@example core/di/ts/viewChild/view_child_example.ts region='Component'}
|
|
@@ -8550,6 +8779,27 @@ export declare interface ViewChildrenDecorator {
|
|
|
8550
8779
|
* ** Note: *** This config option is **deprecated**, it will be permanently set to `true` and
|
|
8551
8780
|
* removed in future versions of Angular.
|
|
8552
8781
|
*
|
|
8782
|
+
* The following selectors are supported.
|
|
8783
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
8784
|
+
* * A template reference variable as a string (e.g. query `<my-component #cmp></my-component>`
|
|
8785
|
+
* with `@ViewChildren('cmp')`)
|
|
8786
|
+
* * Any provider defined in the child component tree of the current component (e.g.
|
|
8787
|
+
* `@ViewChildren(SomeService) someService: SomeService`)
|
|
8788
|
+
* * Any provider defined through a string token (e.g. `@ViewChildren('someToken') someTokenVal:
|
|
8789
|
+
* any`)
|
|
8790
|
+
* * A `TemplateRef` (e.g. query `<ng-template></ng-template>` with `@ViewChildren(TemplateRef)
|
|
8791
|
+
* template;`)
|
|
8792
|
+
*
|
|
8793
|
+
* In addition, multiple string selectors can be separated with a comma (e.g.
|
|
8794
|
+
* `@ViewChildren('cmp1,cmp2')`)
|
|
8795
|
+
*
|
|
8796
|
+
* The following values are supported by `read`:
|
|
8797
|
+
* * Any class with the `@Component` or `@Directive` decorator
|
|
8798
|
+
* * Any provider defined on the injector of the component that is matched by the `selector` of
|
|
8799
|
+
* this query
|
|
8800
|
+
* * Any provider defined through a string token (e.g. `{provide: 'token', useValue: 'val'}`)
|
|
8801
|
+
* * `TemplateRef`, `ElementRef`, and `ViewContainerRef`
|
|
8802
|
+
*
|
|
8553
8803
|
* @usageNotes
|
|
8554
8804
|
*
|
|
8555
8805
|
* {@example core/di/ts/viewChildren/view_children_howto.ts region='HowTo'}
|