Compare commits
442 Commits
10.1.0-nex
...
10.0.7
Author | SHA1 | Date | |
---|---|---|---|
1de4fe5dbf | |||
879ff08f0e | |||
a15d7ac1da | |||
4a6abbdfc6 | |||
78eb5f6777 | |||
0cdb5231c2 | |||
5af845d049 | |||
a5c28497b5 | |||
801ad62ae3 | |||
7d4d2e29b0 | |||
c33f719ddc | |||
69fc6b4f75 | |||
5ec4c02a43 | |||
f0489ee72a | |||
d0f625305b | |||
c15a58fa2b | |||
3d67d1970b | |||
ce08a3c8c7 | |||
bc29712271 | |||
cc48b5c066 | |||
deba0e21f1 | |||
0469d9240a | |||
cdda60a430 | |||
7570356bfa | |||
c4a97d822e | |||
fc4dfc5eb1 | |||
25d95dae6d | |||
1c4fcce2a1 | |||
6e73faaed7 | |||
41c9910613 | |||
aaddef213d | |||
02f3aee1db | |||
c27ba96093 | |||
c5a474cb54 | |||
d5264f5645 | |||
0cd4b87021 | |||
b1e7775a8a | |||
87f5feff11 | |||
c3ddc3d6b1 | |||
cec39a7d16 | |||
c6c8e15813 | |||
752fd14fe5 | |||
776067cd43 | |||
e87a46be21 | |||
89a7ff3ada | |||
3d6e50dc02 | |||
264950bbf2 | |||
84c5be0b5b | |||
eda8f2f8b9 | |||
cc52945d00 | |||
07f184a69d | |||
a123ef58b1 | |||
024126dde4 | |||
4275c34818 | |||
c4e6f585c5 | |||
7467fd36b9 | |||
aca01985fd | |||
eb5e14e6e0 | |||
b8af10902f | |||
f411c9e5b9 | |||
7f455e6eec | |||
e36caafa52 | |||
5e89d98876 | |||
200dbd4860 | |||
c90952884a | |||
7c2d8fc672 | |||
a50a688aaf | |||
6ec7297e43 | |||
f264cd1cb8 | |||
fc17bddcde | |||
0765626761 | |||
f146b34042 | |||
f899d6ea44 | |||
c18d7a1469 | |||
2c7ff82f31 | |||
3f8f3a2daa | |||
f5eeb1a714 | |||
2af3d9c040 | |||
4664acce50 | |||
3797861dfe | |||
d6d3984524 | |||
c17f5c10cc | |||
9cb318f5a2 | |||
b026dd8b52 | |||
0ebc316311 | |||
dc412c5f02 | |||
e80278cf02 | |||
307699ac89 | |||
4df0b7e9de | |||
371831f9cb | |||
8e305e7099 | |||
481df830ad | |||
14b4718cc2 | |||
7b6e73cb98 | |||
f2ca4634e2 | |||
d30cf2f9d6 | |||
e9cb6fbe87 | |||
99960a98d2 | |||
9ac3383d01 | |||
06ac75724f | |||
a1d691ecc8 | |||
6e329721be | |||
739bf5c325 | |||
ee340b7c6c | |||
17ddab98fb | |||
4f65f473e4 | |||
527a04d21e | |||
f2ee468d76 | |||
0320096538 | |||
7abb48adfe | |||
b40d3c0817 | |||
0e5617152a | |||
dba402344f | |||
13d176302b | |||
e3b801053a | |||
6626739798 | |||
396033da80 | |||
02ee9d2938 | |||
a4c7f183d7 | |||
d690eec88f | |||
10e4dfae27 | |||
f8d948b46b | |||
9cf78d5701 | |||
45471dbbd6 | |||
387e8386d1 | |||
eec6e4be7a | |||
b711f25892 | |||
788f0453f7 | |||
45b1775a53 | |||
53e4ff72d2 | |||
7813a7d129 | |||
c0ced6dc2d | |||
8157ee87b0 | |||
ab051aba27 | |||
5a61ef0c49 | |||
c451dbda9f | |||
0d38288078 | |||
2e9b953e9d | |||
a94383f168 | |||
75c40ddd61 | |||
86a75a0670 | |||
c776825fdd | |||
1cc9383d91 | |||
8ed1e53e99 | |||
7833c88ac4 | |||
12f177399f | |||
5be32366be | |||
5b7d2eeabf | |||
6cd10a1b10 | |||
822652aa0d | |||
cf47ace493 | |||
0595f11950 | |||
35df312ea4 | |||
489eb8519e | |||
b76a2dc2cb | |||
f2f5f7fc6e | |||
8ee23ba67b | |||
ecb422b360 | |||
60389d5441 | |||
b186db70db | |||
324b6f1b1a | |||
cdba1d37a4 | |||
dc42c97ee4 | |||
bc00e8d312 | |||
720b71d01f | |||
1132b07c53 | |||
9230194794 | |||
d724896f04 | |||
29866dfb91 | |||
a249622159 | |||
9f2393fb80 | |||
d5f8040d0a | |||
e0b8ea136b | |||
879b2273c1 | |||
f24972b1b1 | |||
d2886b3bb4 | |||
f296fea112 | |||
2605fc46e7 | |||
9d54b3a14b | |||
d09a6283ed | |||
1c168c3a44 | |||
0f74479c47 | |||
790bb949f6 | |||
2adcad6dd2 | |||
242ef1ace1 | |||
842b6a1247 | |||
98335529eb | |||
ca7ee794bf | |||
f9f2ba6faf | |||
aea1d211d4 | |||
57a518a36d | |||
29b83189b0 | |||
1d3df7885d | |||
fd06ffa2af | |||
36a1622dd1 | |||
7a91b23cb5 | |||
4b90b6a226 | |||
b13daa4cdf | |||
0c6f026828 | |||
a2520bd267 | |||
b928a209a4 | |||
89e16ed6a5 | |||
1a1f99af37 | |||
df2cd37ed2 | |||
12a71bc6bc | |||
7d270c235a | |||
b0b7248504 | |||
78460c1848 | |||
75b119eafc | |||
64b0ae93f7 | |||
7c0b25f5a6 | |||
07b5df3a19 | |||
e7023726f4 | |||
a9ccd9254c | |||
335f3271d2 | |||
7f93f7ef47 | |||
cf46a87fcd | |||
ad6680f602 | |||
5e287f67af | |||
ecfe6e0609 | |||
df9790dd11 | |||
67cfc4c9bc | |||
a68e623c80 | |||
9e3915ba48 | |||
ba2de61748 | |||
a9a4edebe2 | |||
64f2ffa166 | |||
13020b9cc2 | |||
96b96fba0f | |||
2cbe53a9ba | |||
48755114e5 | |||
a5d5f67be7 | |||
dfb58c44a2 | |||
69948ce919 | |||
3190ccf3b2 | |||
a8ea8173aa | |||
e13a49d1f0 | |||
2f0b8f675a | |||
c2aed033ba | |||
0f8a780b0d | |||
c5bc2e77c8 | |||
079310dc7c | |||
0d2cdf6165 | |||
436dde271f | |||
96891a076f | |||
9ce0067bdf | |||
345940bbc1 | |||
c49507b289 | |||
c730142508 | |||
27aa00b15f | |||
36a00a255b | |||
0e3249c89b | |||
920019ab70 | |||
82c8b44db7 | |||
bb3a307d5a | |||
dcb0ddaf5e | |||
4c1edd52c5 | |||
d512e27979 | |||
0619d82e0b | |||
a4038d5b94 | |||
e3d5e1fab7 | |||
035036308a | |||
0d29259d9b | |||
26b0f3dc96 | |||
5c9306b0fe | |||
3befb0e4b9 | |||
97bb88f10b | |||
6c7467a58b | |||
c579a85c12 | |||
400fdd08fd | |||
c1fe6c9c81 | |||
c58a0bea91 | |||
88a934b93c | |||
cde5cced69 | |||
472bedd3ea | |||
d8a06d03bd | |||
32020f9fb3 | |||
d574b14934 | |||
00c5d89e7d | |||
d2c8aefe64 | |||
ba796bbdd3 | |||
a0bb2ba7b7 | |||
f9fa3b5b6c | |||
f89d438116 | |||
1abe791d46 | |||
1502ae78b6 | |||
bad6e719de | |||
8c7129f3d2 | |||
dbff6f71e1 | |||
fcd934ccf6 | |||
45a8f340d9 | |||
5856513405 | |||
01fa3ee5c3 | |||
b8d69ffdf3 | |||
7ef60ec2a9 | |||
83f905c0e1 | |||
72ba3a3918 | |||
df10597da4 | |||
5db2e794a9 | |||
486aa06747 | |||
01ce1b32df | |||
c78b0b2c51 | |||
9ade1c3ea3 | |||
315a4cfcd4 | |||
11c04027ab | |||
eabe3b4c39 | |||
d471454675 | |||
bf57776b59 | |||
a32579ae5b | |||
780601d27a | |||
c909e731d7 | |||
9b8eb42354 | |||
0757174e8e | |||
3a43cdefe8 | |||
38c48beddd | |||
ad5749fb04 | |||
f6a838e9ee | |||
a6d1f4aaf1 | |||
eca8d11ee2 | |||
a195b7dbe4 | |||
083d7ec902 | |||
9d2d0cae6d | |||
c2f4a9bf71 | |||
231095fe8a | |||
28a532483a | |||
83853a215d | |||
8248307a99 | |||
67bd88b19a | |||
9f698b4de0 | |||
742f3d6787 | |||
323651bd38 | |||
9d397eb5a1 | |||
6114cd2bd4 | |||
d494f7bd5e | |||
ec6a7ab721 | |||
ad6d2b4619 | |||
c093390010 | |||
acd69f2be2 | |||
5d2f341653 | |||
420d1c35f5 | |||
08647267bb | |||
215d50d2f6 | |||
bf2cb6fa48 | |||
e97a2d4123 | |||
585e3f6adc | |||
7f77ce1a48 | |||
a1616ce181 | |||
1c22dff714 | |||
8d1d6e8f70 | |||
e7f4aba5a3 | |||
fdbe9f5d9f | |||
8bead6bfdd | |||
52dda73dbb | |||
31b3888a2f | |||
6f938470c2 | |||
776c4afc03 | |||
536dd647c6 | |||
51d581ab27 | |||
75294e7dad | |||
04bada7a9d | |||
2349143477 | |||
e9bff5fe9f | |||
411cb0cb92 | |||
53e1fb3554 | |||
2cb3b66640 | |||
5af3144330 | |||
e4043cbb3a | |||
fff424a35f | |||
b5d1c8b05a | |||
d713e33cc4 | |||
3d327d25f0 | |||
077283bf0f | |||
9ec25ea036 | |||
878cfe669c | |||
5f0be3cb2e | |||
9e28e14c08 | |||
954d002884 | |||
0a48591e53 | |||
d37c723951 | |||
9078ca557e | |||
2be1ef6ba0 | |||
47c02efccb | |||
d7ecfb432a | |||
59abf4a33f | |||
d6e715e726 | |||
fcfcd1037c | |||
f3ccd29e7b | |||
5c0bdae809 | |||
838902556b | |||
c6872c02d8 | |||
819982ea20 | |||
f9daa136c3 | |||
6a0d2ed6c8 | |||
2c1f35e794 | |||
5345e8da45 | |||
e35269dd87 | |||
60a03b7ef7 | |||
305b5a3887 | |||
bc549361d3 | |||
084b627f2e | |||
6755d00601 | |||
cba1da3e44 | |||
7be8bb1489 | |||
c7c0c1f626 | |||
3aa4629f92 | |||
2d86dbb090 | |||
91767ff0f9 | |||
078b004ecc | |||
930d204d83 | |||
8d82cdfc77 | |||
cb6996b5c3 | |||
a4f7740332 | |||
ba0faa2f77 | |||
3e68029522 | |||
b4e26b5828 | |||
15cf7fcac2 | |||
24ff0eb13b | |||
cf86f72eb7 | |||
61486f14f1 | |||
d16a7f3ecc | |||
82761ec50e | |||
235bfa77a9 | |||
299ae1bb1c | |||
80f7522dab | |||
028921e369 | |||
a4e11bb524 | |||
a4131752d2 | |||
060dcfbba1 | |||
4be7008f80 | |||
4a0d05515e | |||
83ab99c746 | |||
270da1f69f | |||
6b0e46e36c | |||
3642707145 | |||
0ea76edfd8 | |||
d493a83b2b | |||
f1721d5cef | |||
5b3fd6aa82 | |||
6f829180f7 | |||
27b95ba64a | |||
ef405b1e90 | |||
441073bad5 |
@ -731,8 +731,8 @@ jobs:
|
|||||||
- run: yarn --cwd packages/zone.js promisetest
|
- run: yarn --cwd packages/zone.js promisetest
|
||||||
- run: yarn --cwd packages/zone.js promisefinallytest
|
- run: yarn --cwd packages/zone.js promisefinallytest
|
||||||
- run: yarn bazel build //packages/zone.js:npm_package &&
|
- run: yarn bazel build //packages/zone.js:npm_package &&
|
||||||
cp dist/bin/packages/zone.js/npm_package/bundles/zone-mix.umd.js ./packages/zone.js/test/extra/ &&
|
cp dist/bin/packages/zone.js/npm_package/dist/zone-mix.js ./packages/zone.js/test/extra/ &&
|
||||||
cp dist/bin/packages/zone.js/npm_package/bundles/zone-patch-electron.umd.js ./packages/zone.js/test/extra/ &&
|
cp dist/bin/packages/zone.js/npm_package/dist/zone-patch-electron.js ./packages/zone.js/test/extra/ &&
|
||||||
yarn --cwd packages/zone.js electrontest
|
yarn --cwd packages/zone.js electrontest
|
||||||
- run: yarn --cwd packages/zone.js jesttest
|
- run: yarn --cwd packages/zone.js jesttest
|
||||||
|
|
||||||
|
6
.github/angular-robot.yml
vendored
6
.github/angular-robot.yml
vendored
@ -154,6 +154,12 @@ triage:
|
|||||||
-
|
-
|
||||||
- "type: RFC / Discussion / question"
|
- "type: RFC / Discussion / question"
|
||||||
- "comp: *"
|
- "comp: *"
|
||||||
|
-
|
||||||
|
- "type: confusing"
|
||||||
|
- "comp: *"
|
||||||
|
-
|
||||||
|
- "type: use-case"
|
||||||
|
- "comp: *"
|
||||||
|
|
||||||
# options for the triage PR plugin
|
# options for the triage PR plugin
|
||||||
triagePR:
|
triagePR:
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -42,3 +42,6 @@ yarn-error.log
|
|||||||
|
|
||||||
.notes.md
|
.notes.md
|
||||||
baseline.json
|
baseline.json
|
||||||
|
|
||||||
|
# Ignore .history for the xyz.local-history VSCode extension
|
||||||
|
.history
|
||||||
|
196
.pullapprove.yml
196
.pullapprove.yml
@ -67,6 +67,25 @@ version: 3
|
|||||||
# Meta field that goes unused by PullApprove to allow for defining aliases to be
|
# Meta field that goes unused by PullApprove to allow for defining aliases to be
|
||||||
# used throughout the config.
|
# used throughout the config.
|
||||||
meta:
|
meta:
|
||||||
|
# The following groups have no file based conditions and will be initially `active` on all PRs
|
||||||
|
# - `global-approvers`
|
||||||
|
# - `global-docs-approvers`
|
||||||
|
# - `required-minimum-review`
|
||||||
|
#
|
||||||
|
# By checking the number of active/pending/rejected groups when these are excluded, we can determine
|
||||||
|
# if any other groups are matched.
|
||||||
|
#
|
||||||
|
# Note: Because all inactive groups start as pending, we are only checking pending and rejected active groups.
|
||||||
|
#
|
||||||
|
# Also note that the ordering of groups matters in this file. The only groups visible to the current
|
||||||
|
# one are those that appear above it.
|
||||||
|
no-groups-above-this-pending: &no-groups-above-this-pending
|
||||||
|
len(groups.active.pending.exclude("required-minimum-review").exclude("global-approvers").exclude("global-docs-approvers")) == 0
|
||||||
|
no-groups-above-this-rejected: &no-groups-above-this-rejected
|
||||||
|
len(groups.active.rejected.exclude("required-minimum-review").exclude("global-approvers").exclude("global-docs-approvers")) == 0
|
||||||
|
no-groups-above-this-active: &no-groups-above-this-active
|
||||||
|
len(groups.active.exclude("required-minimum-review").exclude("global-approvers").exclude("global-docs-approvers")) == 0
|
||||||
|
|
||||||
can-be-global-approved: &can-be-global-approved "\"global-approvers\" not in groups.approved"
|
can-be-global-approved: &can-be-global-approved "\"global-approvers\" not in groups.approved"
|
||||||
can-be-global-docs-approved: &can-be-global-docs-approved "\"global-docs-approvers\" not in groups.approved"
|
can-be-global-docs-approved: &can-be-global-docs-approved "\"global-docs-approvers\" not in groups.approved"
|
||||||
defaults: &defaults
|
defaults: &defaults
|
||||||
@ -96,6 +115,54 @@ pullapprove_conditions:
|
|||||||
|
|
||||||
|
|
||||||
groups:
|
groups:
|
||||||
|
# =========================================================
|
||||||
|
# Require review on all PRs
|
||||||
|
#
|
||||||
|
# All PRs require at least one review. This rule will not
|
||||||
|
# request any reviewers, however will require that at least
|
||||||
|
# one review is provided before the group is satisfied.
|
||||||
|
# =========================================================
|
||||||
|
required-minimum-review:
|
||||||
|
reviews:
|
||||||
|
request: 0 # Do not request any reviews from the reviewer group
|
||||||
|
required: 1 # Require that all PRs have approval from at least one of the users in the group
|
||||||
|
author_value: 0 # The author of the PR cannot provide an approval for themself
|
||||||
|
reviewers:
|
||||||
|
users:
|
||||||
|
- aikidave # Dave Shevitz
|
||||||
|
- alan-agius4 # Alan Agius
|
||||||
|
- alxhub # Alex Rickabaugh
|
||||||
|
- AndrewKushnir # Andrew Kushnir
|
||||||
|
- andrewseguin # Andrew Seguin
|
||||||
|
- atscott # Andrew Scott
|
||||||
|
- ayazhafiz # Ayaz Hafiz
|
||||||
|
- clydin # Charles Lyding
|
||||||
|
- crisbeto # Kristiyan Kostadinov
|
||||||
|
- dennispbrown # Denny Brown
|
||||||
|
- devversion # Paul Gschwendtner
|
||||||
|
- dgp1130 # Doug Parker
|
||||||
|
- filipesilva # Filipe Silva
|
||||||
|
- gkalpak # Georgios Kalpakas
|
||||||
|
- gregmagolan # Greg Magolan
|
||||||
|
- IgorMinar # Igor Minar
|
||||||
|
- jbogarthyde # Judy Bogart
|
||||||
|
- jelbourn # Jeremy Elbourn
|
||||||
|
- JiaLiPassion # Jia Li
|
||||||
|
- JoostK # Joost Koehoorn
|
||||||
|
- josephperrott # Joey Perrott
|
||||||
|
- juleskremer # Jules Kremer
|
||||||
|
- kapunahelewong # Kapunahele Wong
|
||||||
|
- kara # Kara Erickson
|
||||||
|
- kyliau # Keen Yee Liau
|
||||||
|
- manughub # Manu Murthy
|
||||||
|
- mgechev # Minko Gechev
|
||||||
|
- mhevery # Miško Hevery
|
||||||
|
- michaelprentice # Michael Prentice
|
||||||
|
- mmalerba # Miles Malerba
|
||||||
|
- petebacondarwin # Pete Bacon Darwin
|
||||||
|
- pkozlowski-opensource # Pawel Kozlowski
|
||||||
|
- StephenFluin # Stephen Fluin
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Global Approvers
|
# Global Approvers
|
||||||
#
|
#
|
||||||
@ -132,58 +199,6 @@ groups:
|
|||||||
required: 1
|
required: 1
|
||||||
reviewed_for: required
|
reviewed_for: required
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# Require review on all PRs
|
|
||||||
#
|
|
||||||
# All PRs require at least one review. This rule will not
|
|
||||||
# request any reviewers, however will require that at least
|
|
||||||
# one review is provided before the group is satisfied.
|
|
||||||
# =========================================================
|
|
||||||
required-minimum-review:
|
|
||||||
conditions:
|
|
||||||
- *can-be-global-approved
|
|
||||||
- *can-be-global-docs-approved
|
|
||||||
reviews:
|
|
||||||
request: 0 # Do not request any reviews from the reviewer group
|
|
||||||
required: 1 # Require that all PRs have approval from at least one of the users in the group
|
|
||||||
author_value: 0 # The author of the PR cannot provide an approval for themself
|
|
||||||
reviewers:
|
|
||||||
users:
|
|
||||||
- aikidave # Dave Shevitz
|
|
||||||
- alan-agius4 # Alan Agius
|
|
||||||
- alxhub # Alex Rickabaugh
|
|
||||||
- AndrewKushnir # Andrew Kushnir
|
|
||||||
- andrewseguin # Andrew Seguin
|
|
||||||
- atscott # Andrew Scott
|
|
||||||
- ayazhafiz # Ayaz Hafiz
|
|
||||||
- clydin # Charles Lyding
|
|
||||||
- crisbeto # Kristiyan Kostadinov
|
|
||||||
- dennispbrown # Denny Brown
|
|
||||||
- devversion # Paul Gschwendtner
|
|
||||||
- dgp1130 # Doug Parker
|
|
||||||
- filipesilva # Filipe Silva
|
|
||||||
- gkalpak # Georgios Kalpakas
|
|
||||||
- gregmagolan # Greg Magolan
|
|
||||||
- IgorMinar # Igor Minar
|
|
||||||
- jbogarthyde # Judy Bogart
|
|
||||||
- jelbourn # Jeremy Elbourn
|
|
||||||
- JiaLiPassion # Jia Li
|
|
||||||
- JoostK # Joost Koehoorn
|
|
||||||
- josephperrott # Joey Perrott
|
|
||||||
- juleskremer # Jules Kremer
|
|
||||||
- kapunahelewong # Kapunahele Wong
|
|
||||||
- kara # Kara Erickson
|
|
||||||
- kyliau # Keen Yee Liau
|
|
||||||
- manughub # Manu Murthy
|
|
||||||
- matsko # Matias Niemela
|
|
||||||
- mgechev # Minko Gechev
|
|
||||||
- mhevery # Miško Hevery
|
|
||||||
- mmalerba # Miles Malerba
|
|
||||||
- petebacondarwin # Pete Bacon Darwin
|
|
||||||
- pkozlowski-opensource # Pawel Kozlowski
|
|
||||||
- Splaktar # Michael Prentice
|
|
||||||
- StephenFluin # Stephen Fluin
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Framework: Animations
|
# Framework: Animations
|
||||||
# =========================================================
|
# =========================================================
|
||||||
@ -206,7 +221,9 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- matsko
|
- crisbeto
|
||||||
|
- IgorMinar
|
||||||
|
- jelbourn
|
||||||
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
@ -315,7 +332,6 @@ groups:
|
|||||||
'aio/content/images/guide/dependency-injection-in-action/**',
|
'aio/content/images/guide/dependency-injection-in-action/**',
|
||||||
'aio/content/guide/dependency-injection-navtree.md',
|
'aio/content/guide/dependency-injection-navtree.md',
|
||||||
'aio/content/guide/dependency-injection-providers.md',
|
'aio/content/guide/dependency-injection-providers.md',
|
||||||
'aio/content/guide/lightweight-injection-tokens.md',
|
|
||||||
'aio/content/guide/displaying-data.md',
|
'aio/content/guide/displaying-data.md',
|
||||||
'aio/content/examples/displaying-data/**',
|
'aio/content/examples/displaying-data/**',
|
||||||
'aio/content/images/guide/displaying-data/**',
|
'aio/content/images/guide/displaying-data/**',
|
||||||
@ -346,20 +362,31 @@ groups:
|
|||||||
'aio/content/guide/ngmodule-vs-jsmodule.md',
|
'aio/content/guide/ngmodule-vs-jsmodule.md',
|
||||||
'aio/content/guide/module-types.md',
|
'aio/content/guide/module-types.md',
|
||||||
'aio/content/guide/template-syntax.md',
|
'aio/content/guide/template-syntax.md',
|
||||||
|
'aio/content/guide/built-in-template-functions.md',
|
||||||
'aio/content/examples/built-in-template-functions/**',
|
'aio/content/examples/built-in-template-functions/**',
|
||||||
|
'aio/content/guide/event-binding.md',
|
||||||
'aio/content/examples/event-binding/**',
|
'aio/content/examples/event-binding/**',
|
||||||
|
'aio/content/guide/interpolation.md',
|
||||||
'aio/content/examples/interpolation/**',
|
'aio/content/examples/interpolation/**',
|
||||||
'aio/content/examples/template-syntax/**',
|
'aio/content/examples/template-syntax/**',
|
||||||
'aio/content/images/guide/template-syntax/**',
|
'aio/content/images/guide/template-syntax/**',
|
||||||
|
'aio/content/guide/binding-syntax.md',
|
||||||
'aio/content/examples/binding-syntax/**',
|
'aio/content/examples/binding-syntax/**',
|
||||||
|
'aio/content/guide/property-binding.md',
|
||||||
'aio/content/examples/property-binding/**',
|
'aio/content/examples/property-binding/**',
|
||||||
|
'aio/content/guide/attribute-binding.md',
|
||||||
'aio/content/examples/attribute-binding/**',
|
'aio/content/examples/attribute-binding/**',
|
||||||
|
'aio/content/guide/two-way-binding.md',
|
||||||
'aio/content/examples/two-way-binding/**',
|
'aio/content/examples/two-way-binding/**',
|
||||||
|
'aio/content/guide/built-in-directives.md',
|
||||||
'aio/content/examples/built-in-directives/**',
|
'aio/content/examples/built-in-directives/**',
|
||||||
'aio/content/images/guide/built-in-directives/**',
|
'aio/content/images/guide/built-in-directives/**',
|
||||||
|
'aio/content/guide/template-reference-variables.md',
|
||||||
'aio/content/examples/template-reference-variables/**',
|
'aio/content/examples/template-reference-variables/**',
|
||||||
|
'aio/content/guide/inputs-outputs.md',
|
||||||
'aio/content/examples/inputs-outputs/**',
|
'aio/content/examples/inputs-outputs/**',
|
||||||
'aio/content/images/guide/inputs-outputs/**',
|
'aio/content/images/guide/inputs-outputs/**',
|
||||||
|
'aio/content/guide/template-expression-operators.md',
|
||||||
'aio/content/examples/template-expression-operators/**',
|
'aio/content/examples/template-expression-operators/**',
|
||||||
'aio/content/guide/pipes.md',
|
'aio/content/guide/pipes.md',
|
||||||
'aio/content/examples/pipes/**',
|
'aio/content/examples/pipes/**',
|
||||||
@ -374,7 +401,9 @@ groups:
|
|||||||
'aio/content/guide/sharing-ngmodules.md',
|
'aio/content/guide/sharing-ngmodules.md',
|
||||||
'aio/content/guide/structural-directives.md',
|
'aio/content/guide/structural-directives.md',
|
||||||
'aio/content/examples/structural-directives/**',
|
'aio/content/examples/structural-directives/**',
|
||||||
|
'aio/content/guide/svg-in-templates.md',
|
||||||
'aio/content/images/guide/structural-directives/**',
|
'aio/content/images/guide/structural-directives/**',
|
||||||
|
'aio/content/guide/template-statements.md',
|
||||||
'aio/content/guide/user-input.md',
|
'aio/content/guide/user-input.md',
|
||||||
'aio/content/examples/user-input/**',
|
'aio/content/examples/user-input/**',
|
||||||
'aio/content/images/guide/user-input/**'
|
'aio/content/images/guide/user-input/**'
|
||||||
@ -754,21 +783,6 @@ groups:
|
|||||||
- JiaLiPassion
|
- JiaLiPassion
|
||||||
- mhevery
|
- mhevery
|
||||||
|
|
||||||
# =========================================================
|
|
||||||
# in-memory-web-api
|
|
||||||
# =========================================================
|
|
||||||
in-memory-web-api:
|
|
||||||
conditions:
|
|
||||||
- *can-be-global-approved
|
|
||||||
- *can-be-global-docs-approved
|
|
||||||
- >
|
|
||||||
contains_any_globs(files, [
|
|
||||||
'packages/misc/angular-in-memory-web-api/**',
|
|
||||||
])
|
|
||||||
reviewers:
|
|
||||||
users:
|
|
||||||
- IgorMinar
|
|
||||||
- crisbeto
|
|
||||||
|
|
||||||
# =========================================================
|
# =========================================================
|
||||||
# Benchpress
|
# Benchpress
|
||||||
@ -1128,6 +1142,8 @@ groups:
|
|||||||
public-api:
|
public-api:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
conditions:
|
conditions:
|
||||||
|
- *no-groups-above-this-pending
|
||||||
|
- *no-groups-above-this-rejected
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
@ -1141,13 +1157,16 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- alxhub
|
- AndrewKushnir
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
|
- alxhub
|
||||||
|
- atscott
|
||||||
- jelbourn
|
- jelbourn
|
||||||
|
- petebacondarwin
|
||||||
- pkozlowski-opensource
|
- pkozlowski-opensource
|
||||||
reviews:
|
reviews:
|
||||||
request: -1 # request reviews from everyone
|
request: 4 # Request reviews from four people
|
||||||
required: 3 # require at least 3 approvals
|
required: 3 # Require that three people approve
|
||||||
reviewed_for: required
|
reviewed_for: required
|
||||||
|
|
||||||
|
|
||||||
@ -1157,6 +1176,8 @@ groups:
|
|||||||
size-tracking:
|
size-tracking:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
conditions:
|
conditions:
|
||||||
|
- *no-groups-above-this-pending
|
||||||
|
- *no-groups-above-this-rejected
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
@ -1164,13 +1185,16 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
- alxhub
|
- AndrewKushnir
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
|
- alxhub
|
||||||
|
- atscott
|
||||||
- jelbourn
|
- jelbourn
|
||||||
|
- petebacondarwin
|
||||||
- pkozlowski-opensource
|
- pkozlowski-opensource
|
||||||
reviews:
|
reviews:
|
||||||
request: -1 # request reviews from everyone
|
request: 4 # Request reviews from four people
|
||||||
required: 2 # require at least 2 approvals
|
required: 2 # Require that two people approve
|
||||||
reviewed_for: required
|
reviewed_for: required
|
||||||
|
|
||||||
|
|
||||||
@ -1180,6 +1204,8 @@ groups:
|
|||||||
circular-dependencies:
|
circular-dependencies:
|
||||||
<<: *defaults
|
<<: *defaults
|
||||||
conditions:
|
conditions:
|
||||||
|
- *no-groups-above-this-pending
|
||||||
|
- *no-groups-above-this-rejected
|
||||||
- *can-be-global-approved
|
- *can-be-global-approved
|
||||||
- >
|
- >
|
||||||
contains_any_globs(files, [
|
contains_any_globs(files, [
|
||||||
@ -1187,9 +1213,12 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
|
- AndrewKushnir
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
|
- alxhub
|
||||||
|
- atscott
|
||||||
- jelbourn
|
- jelbourn
|
||||||
- josephperrott
|
- petebacondarwin
|
||||||
- pkozlowski-opensource
|
- pkozlowski-opensource
|
||||||
|
|
||||||
|
|
||||||
@ -1210,7 +1239,13 @@ groups:
|
|||||||
])
|
])
|
||||||
reviewers:
|
reviewers:
|
||||||
users:
|
users:
|
||||||
|
- AndrewKushnir
|
||||||
- IgorMinar
|
- IgorMinar
|
||||||
|
- alxhub
|
||||||
|
- atscott
|
||||||
|
- jelbourn
|
||||||
|
- josephperrott
|
||||||
|
- mhevery
|
||||||
|
|
||||||
|
|
||||||
# ====================================================
|
# ====================================================
|
||||||
@ -1237,14 +1272,7 @@ groups:
|
|||||||
# `global-approvers` can still approve PRs that match this `fallback` rule,
|
# `global-approvers` can still approve PRs that match this `fallback` rule,
|
||||||
# but that should be an exception and not an expectation.
|
# but that should be an exception and not an expectation.
|
||||||
conditions:
|
conditions:
|
||||||
# The following groups have no file based conditions and will be initially `active` on all PRs
|
- *no-groups-above-this-active
|
||||||
# - `global-approvers`
|
|
||||||
# - `global-docs-approvers`
|
|
||||||
# - `required-minimum-review`
|
|
||||||
#
|
|
||||||
# By checking the number of active groups when these are excluded, we can determine
|
|
||||||
# if any other groups are matched.
|
|
||||||
- len(groups.active.exclude("required-minimum-review").exclude("global-approvers").exclude("global-docs-approvers")) == 0
|
|
||||||
# When any of the `global-*` groups is approved, they cause other groups to deactivate.
|
# When any of the `global-*` groups is approved, they cause other groups to deactivate.
|
||||||
# In those cases, the condition above would evaluate to `true` while in reality, only a global
|
# In those cases, the condition above would evaluate to `true` while in reality, only a global
|
||||||
# approval has been provided. To ensure we don't activate the fallback group in such cases,
|
# approval has been provided. To ensure we don't activate the fallback group in such cases,
|
||||||
|
1
.vscode/recommended-settings.json
vendored
1
.vscode/recommended-settings.json
vendored
@ -26,6 +26,7 @@
|
|||||||
"**/bazel-out": true,
|
"**/bazel-out": true,
|
||||||
"**/dist": true,
|
"**/dist": true,
|
||||||
"**/aio/src/generated": true,
|
"**/aio/src/generated": true,
|
||||||
|
".history": true,
|
||||||
},
|
},
|
||||||
"git.ignoreLimitWarning": true,
|
"git.ignoreLimitWarning": true,
|
||||||
}
|
}
|
@ -20,9 +20,9 @@ filegroup(
|
|||||||
# do not sort
|
# do not sort
|
||||||
srcs = [
|
srcs = [
|
||||||
"@npm//:node_modules/core-js/client/core.js",
|
"@npm//:node_modules/core-js/client/core.js",
|
||||||
"//packages/zone.js/bundles:zone.umd.js",
|
"//packages/zone.js/dist:zone.js",
|
||||||
"//packages/zone.js/bundles:zone-testing.umd.js",
|
"//packages/zone.js/dist:zone-testing.js",
|
||||||
"//packages/zone.js/bundles:task-tracking.umd.js",
|
"//packages/zone.js/dist:task-tracking.js",
|
||||||
"//:test-events.js",
|
"//:test-events.js",
|
||||||
"//:third_party/shims_for_IE.js",
|
"//:third_party/shims_for_IE.js",
|
||||||
# Including systemjs because it defines `__eval`, which produces correct stack traces.
|
# Including systemjs because it defines `__eval`, which produces correct stack traces.
|
||||||
|
245
CHANGELOG.md
245
CHANGELOG.md
@ -1,56 +1,58 @@
|
|||||||
<a name="10.1.0-next.1"></a>
|
<a name="10.0.7"></a>
|
||||||
# 10.1.0-next.1 (2020-07-15)
|
## 10.0.7 (2020-07-30)
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* **bazel:** ng_module rule does not expose flat module information in Ivy ([#36971](https://github.com/angular/angular/issues/36971)) ([1550663](https://github.com/angular/angular/commit/1550663))
|
* **compiler:** Metadata should not include methods on Object.prototype ([#38292](https://github.com/angular/angular/issues/38292)) ([879ff08](https://github.com/angular/angular/commit/879ff08))
|
||||||
* **compiler:** check more cases for pipe usage inside host bindings ([#37883](https://github.com/angular/angular/issues/37883)) ([9322b9a](https://github.com/angular/angular/commit/9322b9a)), closes [#34655](https://github.com/angular/angular/issues/34655) [#37610](https://github.com/angular/angular/issues/37610)
|
|
||||||
* **compiler-cli:** ensure file_system handles mixed Windows drives ([#37959](https://github.com/angular/angular/issues/37959)) ([6b31155](https://github.com/angular/angular/commit/6b31155)), closes [#36777](https://github.com/angular/angular/issues/36777)
|
|
||||||
* **language-service:** remove completion for string ([#37983](https://github.com/angular/angular/issues/37983)) ([10aba15](https://github.com/angular/angular/commit/10aba15))
|
|
||||||
* **ngcc:** report a warning if ngcc tries to use a solution-style tsconfig ([#38003](https://github.com/angular/angular/issues/38003)) ([b358495](https://github.com/angular/angular/commit/b358495)), closes [#36386](https://github.com/angular/angular/issues/36386)
|
|
||||||
* **router:** ensure duplicate popstate/hashchange events are handled correctly ([#37674](https://github.com/angular/angular/issues/37674)) ([9185c6e](https://github.com/angular/angular/commit/9185c6e)), closes [/github.com/angular/angular/issues/16710#issuecomment-646919529](https://github.com//github.com/angular/angular/issues/16710/issues/issuecomment-646919529) [#16710](https://github.com/angular/angular/issues/16710)
|
|
||||||
* **service-worker:** correctly handle relative base href ([#37922](https://github.com/angular/angular/issues/37922)) ([d19ef65](https://github.com/angular/angular/commit/d19ef65)), closes [#25055](https://github.com/angular/angular/issues/25055) [#25055](https://github.com/angular/angular/issues/25055)
|
|
||||||
* **service-worker:** correctly serve `ngsw/state` with a non-root SW scope ([#37922](https://github.com/angular/angular/issues/37922)) ([2156bee](https://github.com/angular/angular/commit/2156bee)), closes [#30505](https://github.com/angular/angular/issues/30505)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="10.1.0-next.0"></a>
|
<a name="10.0.6"></a>
|
||||||
# 10.1.0-next.0 (2020-07-08)
|
## 10.0.6 (2020-07-28)
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* **common:** date pipe gives wrong week number ([#37632](https://github.com/angular/angular/issues/37632)) ([ef1fb6d](https://github.com/angular/angular/commit/ef1fb6d)), closes [#33961](https://github.com/angular/angular/issues/33961)
|
* **compiler:** share identical stylesheets between components in the same file ([#38213](https://github.com/angular/angular/issues/38213)) ([264950b](https://github.com/angular/angular/commit/264950b)), closes [#38204](https://github.com/angular/angular/issues/38204)
|
||||||
* **compiler-cli:** ensure source-maps can handle webpack:// protocol ([#32912](https://github.com/angular/angular/issues/32912)) ([decd95e](https://github.com/angular/angular/commit/decd95e))
|
* **compiler-cli:** Add support for string literal class members ([#38226](https://github.com/angular/angular/issues/38226)) ([b1e7775](https://github.com/angular/angular/commit/b1e7775))
|
||||||
* **compiler-cli:** only read source-map comment from last line ([#32912](https://github.com/angular/angular/issues/32912)) ([07a07e3](https://github.com/angular/angular/commit/07a07e3))
|
* **core:** `Attribute` decorator `attributeName` is mandatory ([#38131](https://github.com/angular/angular/issues/38131)) ([1c4fcce](https://github.com/angular/angular/commit/1c4fcce)), closes [#32658](https://github.com/angular/angular/issues/32658)
|
||||||
* **core:** determine required DOMParser feature availability ([#36578](https://github.com/angular/angular/issues/36578)) ([#36578](https://github.com/angular/angular/issues/36578)) ([c509243](https://github.com/angular/angular/commit/c509243))
|
* **core:** unify the signature between ngZone and noopZone ([#37581](https://github.com/angular/angular/issues/37581)) ([d5264f5](https://github.com/angular/angular/commit/d5264f5))
|
||||||
* **core:** do not trigger CSP alert/report in Firefox and Chrome ([#36578](https://github.com/angular/angular/issues/36578)) ([#36578](https://github.com/angular/angular/issues/36578)) ([b950d46](https://github.com/angular/angular/commit/b950d46)), closes [#25214](https://github.com/angular/angular/issues/25214)
|
|
||||||
* **forms:** handle form groups/arrays own pending async validation ([#22575](https://github.com/angular/angular/issues/22575)) ([77b62a5](https://github.com/angular/angular/commit/77b62a5)), closes [#10064](https://github.com/angular/angular/issues/10064)
|
|
||||||
* **language-service:** non-existent module format in package output ([#37623](https://github.com/angular/angular/issues/37623)) ([413a0fb](https://github.com/angular/angular/commit/413a0fb))
|
|
||||||
* **router:** fix navigation ignoring logic to compare to the browser url ([#37716](https://github.com/angular/angular/issues/37716)) ([a5ffca0](https://github.com/angular/angular/commit/a5ffca0)), closes [#16710](https://github.com/angular/angular/issues/16710) [#13586](https://github.com/angular/angular/issues/13586)
|
<a name="10.0.5"></a>
|
||||||
* **router:** properly compare array queryParams for equality ([#37709](https://github.com/angular/angular/issues/37709)) ([#37860](https://github.com/angular/angular/issues/37860)) ([1801d0c](https://github.com/angular/angular/commit/1801d0c))
|
## 10.0.5 (2020-07-22)
|
||||||
* **router:** remove parenthesis for primary outlet segment after removing auxiliary outlet segment ([#24656](https://github.com/angular/angular/issues/24656)) ([#37163](https://github.com/angular/angular/issues/37163)) ([71f008f](https://github.com/angular/angular/commit/71f008f))
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **compiler:** properly associate source spans for implicitly closed elements ([#38126](https://github.com/angular/angular/issues/38126)) ([e80278c](https://github.com/angular/angular/commit/e80278c)), closes [#36118](https://github.com/angular/angular/issues/36118)
|
||||||
|
* **compiler-cli:** ensure file_system handles mixed Windows drives ([#38030](https://github.com/angular/angular/issues/38030)) ([dba4023](https://github.com/angular/angular/commit/dba4023)), closes [#36777](https://github.com/angular/angular/issues/36777)
|
||||||
|
* **core:** Allow modification of lifecycle hooks any time before bootstrap ([#38119](https://github.com/angular/angular/issues/38119)) ([14b4718](https://github.com/angular/angular/commit/14b4718)), closes [#30497](https://github.com/angular/angular/issues/30497)
|
||||||
|
* **core:** error due to integer overflow when there are too many host bindings ([#38014](https://github.com/angular/angular/issues/38014)) ([7b6e73c](https://github.com/angular/angular/commit/7b6e73c)), closes [#37876](https://github.com/angular/angular/issues/37876) [#37876](https://github.com/angular/angular/issues/37876)
|
||||||
|
* **core:** incorrectly validating properties on ng-content and ng-container ([#37773](https://github.com/angular/angular/issues/37773)) ([17ddab9](https://github.com/angular/angular/commit/17ddab9))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="10.0.4"></a>
|
||||||
|
## 10.0.4 (2020-07-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **bazel:** ng_module rule does not expose flat module information in Ivy ([#36971](https://github.com/angular/angular/issues/36971)) ([b76a2dc](https://github.com/angular/angular/commit/b76a2dc))
|
||||||
|
* **compiler:** check more cases for pipe usage inside host bindings ([#37883](https://github.com/angular/angular/issues/37883)) ([a94383f](https://github.com/angular/angular/commit/a94383f)), closes [#34655](https://github.com/angular/angular/issues/34655) [#37610](https://github.com/angular/angular/issues/37610)
|
||||||
|
* **language-service:** non-existent module format in package output ([#37778](https://github.com/angular/angular/issues/37778)) ([12f1773](https://github.com/angular/angular/commit/12f1773))
|
||||||
|
* **language-service:** remove completion for string ([#37983](https://github.com/angular/angular/issues/37983)) ([387e838](https://github.com/angular/angular/commit/387e838))
|
||||||
|
* **ngcc:** report a warning if ngcc tries to use a solution-style tsconfig ([#38003](https://github.com/angular/angular/issues/38003)) ([e3b8010](https://github.com/angular/angular/commit/e3b8010)), closes [#36386](https://github.com/angular/angular/issues/36386)
|
||||||
|
* **service-worker:** correctly handle relative base href ([#37922](https://github.com/angular/angular/issues/37922)) ([b186db7](https://github.com/angular/angular/commit/b186db7)), closes [#25055](https://github.com/angular/angular/issues/25055) [#25055](https://github.com/angular/angular/issues/25055)
|
||||||
|
* **service-worker:** correctly serve `ngsw/state` with a non-root SW scope ([#37922](https://github.com/angular/angular/issues/37922)) ([dc42c97](https://github.com/angular/angular/commit/dc42c97)), closes [#30505](https://github.com/angular/angular/issues/30505)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* **bazel:** provide LinkablePackageInfo from ng_module ([#37623](https://github.com/angular/angular/issues/37623)) ([6898eab](https://github.com/angular/angular/commit/6898eab))
|
* **bazel:** provide LinkablePackageInfo from ng_module ([#37778](https://github.com/angular/angular/issues/37778)) ([6cd10a1](https://github.com/angular/angular/commit/6cd10a1)), closes [/github.com/bazelbuild/rules_nodejs/blob/9a5de3728b05bf1647bbb87ad99f54e626604705/internal/linker/link_node_modules.bzl#L144-L146](https://github.com//github.com/bazelbuild/rules_nodejs/blob/9a5de3728b05bf1647bbb87ad99f54e626604705/internal/linker/link_node_modules.bzl/issues/L144-L146)
|
||||||
* **compiler-cli:** add `SourceFile.getOriginalLocation()` to sourcemaps package ([#32912](https://github.com/angular/angular/issues/32912)) ([6abb8d0](https://github.com/angular/angular/commit/6abb8d0))
|
|
||||||
* **compiler-cli:** explain why an expression cannot be used in AOT compilations ([#37587](https://github.com/angular/angular/issues/37587)) ([712f1bd](https://github.com/angular/angular/commit/712f1bd))
|
|
||||||
* **core:** support injection token as predicate in queries ([#37506](https://github.com/angular/angular/issues/37506)) ([97dc85b](https://github.com/angular/angular/commit/97dc85b)), closes [#21152](https://github.com/angular/angular/issues/21152) [#36144](https://github.com/angular/angular/issues/36144)
|
|
||||||
* **localize:** expose `canParse()` diagnostics ([#37909](https://github.com/angular/angular/issues/37909)) ([ec32eba](https://github.com/angular/angular/commit/ec32eba)), closes [#37901](https://github.com/angular/angular/issues/37901)
|
|
||||||
* **localize:** implement message extraction tool ([#32912](https://github.com/angular/angular/issues/32912)) ([190561d](https://github.com/angular/angular/commit/190561d))
|
|
||||||
* **platform-browser:** Allow `sms`-URLs ([#31463](https://github.com/angular/angular/issues/31463)) ([fc5c34d](https://github.com/angular/angular/commit/fc5c34d)), closes [#31462](https://github.com/angular/angular/issues/31462)
|
|
||||||
* **platform-server:** add option for absolute URL HTTP support ([#37539](https://github.com/angular/angular/issues/37539)) ([d37049a](https://github.com/angular/angular/commit/d37049a)), closes [#37071](https://github.com/angular/angular/issues/37071)
|
|
||||||
|
|
||||||
|
|
||||||
### Performance Improvements
|
|
||||||
|
|
||||||
* **compiler-cli:** fix regressions in incremental program reuse ([#37641](https://github.com/angular/angular/issues/37641)) ([5103d90](https://github.com/angular/angular/commit/5103d90))
|
|
||||||
* **ngcc:** shortcircuit tokenizing in ESM dependency host ([#37639](https://github.com/angular/angular/issues/37639)) ([bd7f440](https://github.com/angular/angular/commit/bd7f440))
|
|
||||||
* **ngcc:** use `EntryPointManifest` to speed up noop `ProgramBaseEntryPointFinder` ([#37665](https://github.com/angular/angular/issues/37665)) ([9318e23](https://github.com/angular/angular/commit/9318e23))
|
|
||||||
* **router:** apply prioritizedGuardValue operator to optimize CanLoad guards ([#37523](https://github.com/angular/angular/issues/37523)) ([d7dd295](https://github.com/angular/angular/commit/d7dd295))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -64,16 +66,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="9.1.12"></a>
|
|
||||||
## [9.1.12](https://github.com/angular/angular/compare/9.1.11...9.1.12) (2020-07-08)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **core:** infinite loop if injectable using inheritance has a custom decorator ([6c1ab47](https://github.com/angular/angular/commit/6c1ab47)), closes [#35733](https://github.com/angular/angular/issues/35733)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="10.0.2"></a>
|
<a name="10.0.2"></a>
|
||||||
## [10.0.2](https://github.com/angular/angular/compare/10.0.1...10.0.2) (2020-06-30)
|
## [10.0.2](https://github.com/angular/angular/compare/10.0.1...10.0.2) (2020-06-30)
|
||||||
|
|
||||||
@ -185,6 +177,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **compiler:** avoid undefined expressions in holey array ([#36343](https://github.com/angular/angular/issues/36343)) ([5516802](https://github.com/angular/angular/commit/5516802))
|
* **compiler:** avoid undefined expressions in holey array ([#36343](https://github.com/angular/angular/issues/36343)) ([5516802](https://github.com/angular/angular/commit/5516802))
|
||||||
* **compiler:** handle type references to namespaced symbols correctly ([#36106](https://github.com/angular/angular/issues/36106)) ([4aa4e6f](https://github.com/angular/angular/commit/4aa4e6f)), closes [#36006](https://github.com/angular/angular/issues/36006)
|
* **compiler:** handle type references to namespaced symbols correctly ([#36106](https://github.com/angular/angular/issues/36106)) ([4aa4e6f](https://github.com/angular/angular/commit/4aa4e6f)), closes [#36006](https://github.com/angular/angular/issues/36006)
|
||||||
* **compiler:** normalize line endings in ICU expansions ([#36741](https://github.com/angular/angular/issues/36741)) ([70dd27f](https://github.com/angular/angular/commit/70dd27f)), closes [#36725](https://github.com/angular/angular/issues/36725)
|
* **compiler:** normalize line endings in ICU expansions ([#36741](https://github.com/angular/angular/issues/36741)) ([70dd27f](https://github.com/angular/angular/commit/70dd27f)), closes [#36725](https://github.com/angular/angular/issues/36725)
|
||||||
|
* **compiler:** record correct end of expression ([#34690](https://github.com/angular/angular/issues/34690)) ([df890d7](https://github.com/angular/angular/commit/df890d7)), closes [#33477](https://github.com/angular/angular/issues/33477)
|
||||||
* **compiler:** remove outdated and invalid warning for unresolved DI parameters ([#36985](https://github.com/angular/angular/issues/36985)) ([d0280a0](https://github.com/angular/angular/commit/d0280a0))
|
* **compiler:** remove outdated and invalid warning for unresolved DI parameters ([#36985](https://github.com/angular/angular/issues/36985)) ([d0280a0](https://github.com/angular/angular/commit/d0280a0))
|
||||||
* **compiler:** resolve enum values in binary operations ([#36461](https://github.com/angular/angular/issues/36461)) ([64022f5](https://github.com/angular/angular/commit/64022f5)), closes [#35584](https://github.com/angular/angular/issues/35584)
|
* **compiler:** resolve enum values in binary operations ([#36461](https://github.com/angular/angular/issues/36461)) ([64022f5](https://github.com/angular/angular/commit/64022f5)), closes [#35584](https://github.com/angular/angular/issues/35584)
|
||||||
* **compiler:** switch to 'referencedFiles' for shim generation ([#36211](https://github.com/angular/angular/issues/36211)) ([4213e8d](https://github.com/angular/angular/commit/4213e8d))
|
* **compiler:** switch to 'referencedFiles' for shim generation ([#36211](https://github.com/angular/angular/issues/36211)) ([4213e8d](https://github.com/angular/angular/commit/4213e8d))
|
||||||
@ -441,30 +434,6 @@ subscribe to the observable and call markForCheck as needed.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="9.1.11"></a>
|
|
||||||
## [9.1.11](https://github.com/angular/angular/compare/9.1.10...9.1.11) (2020-06-10)
|
|
||||||
|
|
||||||
### Reverts
|
|
||||||
|
|
||||||
* **elements:** fire custom element output events during component initialization ([dc9da17](https://github.com/angular/angular/commit/dc9da17))
|
|
||||||
|
|
||||||
|
|
||||||
<a name="9.1.10"></a>
|
|
||||||
## [9.1.10](https://github.com/angular/angular/compare/9.1.9...9.1.10) (2020-06-09)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **elements:** fire custom element output events during component initialization ([454e073](https://github.com/angular/angular/commit/454e073)), closes [/github.com/angular/angular/blob/c0143cb2abdd172de1b95fd1d2c4cfc738640e28/packages/elements/src/create-custom-element.ts#L167-L170](https://github.com/angular/angular/blob/c0143cb2abdd172de1b95fd1d2c4cfc738640e28/packages/elements/src/create-custom-element.ts/issues/L167-L170) [/github.com/angular/angular/blob/c0143cb2abdd172de1b95fd1d2c4cfc738640e28/packages/elements/src/create-custom-element.ts#L164](https://github.com/angular/angular/blob/c0143cb2abdd172de1b95fd1d2c4cfc738640e28/packages/elements/src/create-custom-element.ts/issues/L164) [/github.com/angular/angular/blob/c0143cb2abdd172de1b95fd1d2c4cfc738640e28/packages/elements/src/component-factory-strategy.ts#L158](https://github.com/angular/angular/blob/c0143cb2abdd172de1b95fd1d2c4cfc738640e28/packages/elements/src/component-factory-strategy.ts/issues/L158) [#36141](https://github.com/angular/angular/issues/36141)
|
|
||||||
|
|
||||||
|
|
||||||
### Performance Improvements
|
|
||||||
|
|
||||||
* **ngcc:** cache parsed tsconfig between runs ([1aae94a](https://github.com/angular/angular/commit/1aae94a)), closes [#37417](https://github.com/angular/angular/issues/37417) [#36882](https://github.com/angular/angular/issues/36882)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="9.1.9"></a>
|
<a name="9.1.9"></a>
|
||||||
## [9.1.9](https://github.com/angular/angular/compare/9.1.8...9.1.9) (2020-05-20)
|
## [9.1.9](https://github.com/angular/angular/compare/9.1.8...9.1.9) (2020-05-20)
|
||||||
|
|
||||||
@ -506,7 +475,6 @@ This release contains various API docs improvements.
|
|||||||
* **compiler-cli**: Revert "fix(compiler-cli): fix case-sensitivity issues in NgtscCompilerHost (#36968)" (#37003)
|
* **compiler-cli**: Revert "fix(compiler-cli): fix case-sensitivity issues in NgtscCompilerHost (#36968)" (#37003)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="9.1.5"></a>
|
<a name="9.1.5"></a>
|
||||||
## [9.1.5](https://github.com/angular/angular/compare/9.1.4...9.1.5) (2020-05-07)
|
## [9.1.5](https://github.com/angular/angular/compare/9.1.4...9.1.5) (2020-05-07)
|
||||||
|
|
||||||
@ -552,7 +520,6 @@ This release contains various API docs improvements.
|
|||||||
* **ngcc:** recognize enum declarations emitted in JavaScript ([#36550](https://github.com/angular/angular/issues/36550)) ([c440165](https://github.com/angular/angular/commit/c440165)), closes [#35584](https://github.com/angular/angular/issues/35584)
|
* **ngcc:** recognize enum declarations emitted in JavaScript ([#36550](https://github.com/angular/angular/issues/36550)) ([c440165](https://github.com/angular/angular/commit/c440165)), closes [#35584](https://github.com/angular/angular/issues/35584)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="9.1.3"></a>
|
<a name="9.1.3"></a>
|
||||||
## [9.1.3](https://github.com/angular/angular/compare/9.1.2...9.1.3) (2020-04-22)
|
## [9.1.3](https://github.com/angular/angular/compare/9.1.2...9.1.3) (2020-04-22)
|
||||||
|
|
||||||
@ -567,8 +534,8 @@ This release contains various API docs improvements.
|
|||||||
* **core:** prevent unknown property check for AOT-compiled components ([#36072](https://github.com/angular/angular/issues/36072)) ([fe1d9ba](https://github.com/angular/angular/commit/fe1d9ba)), closes [#35945](https://github.com/angular/angular/issues/35945)
|
* **core:** prevent unknown property check for AOT-compiled components ([#36072](https://github.com/angular/angular/issues/36072)) ([fe1d9ba](https://github.com/angular/angular/commit/fe1d9ba)), closes [#35945](https://github.com/angular/angular/issues/35945)
|
||||||
* **core:** properly identify modules affected by overrides in TestBed ([#36649](https://github.com/angular/angular/issues/36649)) ([9724169](https://github.com/angular/angular/commit/9724169)), closes [#36619](https://github.com/angular/angular/issues/36619)
|
* **core:** properly identify modules affected by overrides in TestBed ([#36649](https://github.com/angular/angular/issues/36649)) ([9724169](https://github.com/angular/angular/commit/9724169)), closes [#36619](https://github.com/angular/angular/issues/36619)
|
||||||
* **language-service:** properly evaluate types in comparable expressions ([#36529](https://github.com/angular/angular/issues/36529)) ([5bab498](https://github.com/angular/angular/commit/5bab498))
|
* **language-service:** properly evaluate types in comparable expressions ([#36529](https://github.com/angular/angular/issues/36529)) ([5bab498](https://github.com/angular/angular/commit/5bab498))
|
||||||
* **ngcc:** display unlocker process output in sync mode ([#36637](https://github.com/angular/angular/issues/36637)) ([da159bd](https://github.com/angular/angular/commit/da159bd)), closes [/github.com/nodejs/node/issues/3596#issuecomment-250890218](https://github.com/nodejs/node/issues/3596/issues/issuecomment-250890218)
|
* **ngcc:** display unlocker process output in sync mode ([#36637](https://github.com/angular/angular/issues/36637)) ([da159bd](https://github.com/angular/angular/commit/da159bd)), closes [/github.com/nodejs/node/issues/3596#issuecomment-250890218](https://github.com/nodejs/node/issues/3596#issuecomment-250890218)
|
||||||
* **ngcc:** do not use cached file-system ([#36687](https://github.com/angular/angular/issues/36687)) ([18be33a](https://github.com/angular/angular/commit/18be33a)), closes [/github.com/angular/angular-cli/issues/16860#issuecomment-614694269](https://github.com/angular/angular-cli/issues/16860/issues/issuecomment-614694269)
|
* **ngcc:** do not use cached file-system ([#36687](https://github.com/angular/angular/issues/36687)) ([18be33a](https://github.com/angular/angular/commit/18be33a)), closes [/github.com/angular/angular-cli/issues/16860#issuecomment-614694269](https://github.com/angular/angular-cli/issues/16860#issuecomment-614694269)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -589,7 +556,7 @@ This release contains various API docs improvements.
|
|||||||
* **upgrade:** update $locationShim to handle Location changes before initialization ([#36498](https://github.com/angular/angular/issues/36498)) ([a67afcc](https://github.com/angular/angular/commit/a67afcc)), closes [#36492](https://github.com/angular/angular/issues/36492)
|
* **upgrade:** update $locationShim to handle Location changes before initialization ([#36498](https://github.com/angular/angular/issues/36498)) ([a67afcc](https://github.com/angular/angular/commit/a67afcc)), closes [#36492](https://github.com/angular/angular/issues/36492)
|
||||||
|
|
||||||
### Performance Improvements
|
### Performance Improvements
|
||||||
* **ngcc:** only load if it is needed ([#36486](https://github.com/angular/angular/issues/36486)) ([e06512b](https://github.com/angular/angular/commit/e06512b)) * **ngcc:** read dependencies from entry-point manifest ([#36486](https://github.com/angular/angular/issues/36486)) ([918e628](https://github.com/angular/angular/commit/918e628)), closes [#issuecomment-608401834](https://github.com/angular/angular/issues/issuecomment-608401834)
|
* **ngcc:** only load if it is needed ([#36486](https://github.com/angular/angular/issues/36486)) ([e06512b](https://github.com/angular/angular/commit/e06512b)) * **ngcc:** read dependencies from entry-point manifest ([#36486](https://github.com/angular/angular/issues/36486)) ([918e628](https://github.com/angular/angular/commit/918e628)), closes [#issuecomment-608401834](https://github.com/angular/angular#issuecomment-608401834)
|
||||||
* **ngcc:** reduce the size of the entry-point manifest file ([#36486](https://github.com/angular/angular/issues/36486)) ([603b094](https://github.com/angular/angular/commit/603b094))
|
* **ngcc:** reduce the size of the entry-point manifest file ([#36486](https://github.com/angular/angular/issues/36486)) ([603b094](https://github.com/angular/angular/commit/603b094))
|
||||||
|
|
||||||
|
|
||||||
@ -609,7 +576,7 @@ This release contains various API docs improvements.
|
|||||||
* **core:** undecorated-classes migration should handle derived abstract classes ([#35339](https://github.com/angular/angular/issues/35339)) ([a631b99](https://github.com/angular/angular/commit/a631b99))
|
* **core:** undecorated-classes migration should handle derived abstract classes ([#35339](https://github.com/angular/angular/issues/35339)) ([a631b99](https://github.com/angular/angular/commit/a631b99))
|
||||||
* **language-service:** infer type of elements of array-like objects ([#36312](https://github.com/angular/angular/issues/36312)) ([ff523c9](https://github.com/angular/angular/commit/ff523c9)), closes [#36191](https://github.com/angular/angular/issues/36191)
|
* **language-service:** infer type of elements of array-like objects ([#36312](https://github.com/angular/angular/issues/36312)) ([ff523c9](https://github.com/angular/angular/commit/ff523c9)), closes [#36191](https://github.com/angular/angular/issues/36191)
|
||||||
* **language-service:** use the `HtmlAst` to get the span of HTML tag ([#36371](https://github.com/angular/angular/issues/36371)) ([ffa4e11](https://github.com/angular/angular/commit/ffa4e11))
|
* **language-service:** use the `HtmlAst` to get the span of HTML tag ([#36371](https://github.com/angular/angular/issues/36371)) ([ffa4e11](https://github.com/angular/angular/commit/ffa4e11))
|
||||||
* **ngcc:** add process title ([#36448](https://github.com/angular/angular/issues/36448)) ([136596d](https://github.com/angular/angular/commit/136596d)), closes [/github.com/angular/angular/issues/36414#issuecomment-609644282](https://github.com/angular/angular/issues/36414/issues/issuecomment-609644282)
|
* **ngcc:** add process title ([#36448](https://github.com/angular/angular/issues/36448)) ([136596d](https://github.com/angular/angular/commit/136596d)), closes [36414#issuecomment-609644282](https://github.com/angular/angular/issues/36414#issuecomment-609644282)
|
||||||
* **ngcc:** allow ngcc configuration to match pre-release versions of packages ([#36370](https://github.com/angular/angular/issues/36370)) ([cb0a2a0](https://github.com/angular/angular/commit/cb0a2a0))
|
* **ngcc:** allow ngcc configuration to match pre-release versions of packages ([#36370](https://github.com/angular/angular/issues/36370)) ([cb0a2a0](https://github.com/angular/angular/commit/cb0a2a0))
|
||||||
* **ngcc:** correctly detect imported TypeScript helpers ([#36284](https://github.com/angular/angular/issues/36284)) ([879457c](https://github.com/angular/angular/commit/879457c)), closes [#36089](https://github.com/angular/angular/issues/36089)
|
* **ngcc:** correctly detect imported TypeScript helpers ([#36284](https://github.com/angular/angular/issues/36284)) ([879457c](https://github.com/angular/angular/commit/879457c)), closes [#36089](https://github.com/angular/angular/issues/36089)
|
||||||
* **ngcc:** correctly identify relative Windows-style import paths ([#36372](https://github.com/angular/angular/issues/36372)) ([0daa488](https://github.com/angular/angular/commit/0daa488))
|
* **ngcc:** correctly identify relative Windows-style import paths ([#36372](https://github.com/angular/angular/issues/36372)) ([0daa488](https://github.com/angular/angular/commit/0daa488))
|
||||||
@ -686,9 +653,12 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **animations:** allow computeStyle to work on elements created in Node ([#35810](https://github.com/angular/angular/issues/35810)) ([17cf04e](https://github.com/angular/angular/commit/17cf04e))
|
* **animations:** allow computeStyle to work on elements created in Node ([#35810](https://github.com/angular/angular/issues/35810)) ([17cf04e](https://github.com/angular/angular/commit/17cf04e))
|
||||||
* **animations:** false positive when detecting Node in Webpack builds ([#35134](https://github.com/angular/angular/issues/35134)) ([dc4ae4b](https://github.com/angular/angular/commit/dc4ae4b)), closes [#35117](https://github.com/angular/angular/issues/35117)
|
* **animations:** false positive when detecting Node in Webpack builds ([#35134](https://github.com/angular/angular/issues/35134)) ([dc4ae4b](https://github.com/angular/angular/commit/dc4ae4b)), closes [#35117](https://github.com/angular/angular/issues/35117)
|
||||||
* **animations:** process shorthand `margin` and `padding` styles correctly ([#35701](https://github.com/angular/angular/issues/35701)) ([35c9f0d](https://github.com/angular/angular/commit/35c9f0d)), closes [#35463](https://github.com/angular/angular/issues/35463)
|
* **animations:** process shorthand `margin` and `padding` styles correctly ([#35701](https://github.com/angular/angular/issues/35701)) ([35c9f0d](https://github.com/angular/angular/commit/35c9f0d)), closes [#35463](https://github.com/angular/angular/issues/35463)
|
||||||
|
* **bazel:** devserver shows blank page in Windows ([#35159](https://github.com/angular/angular/issues/35159)) ([727f92f](https://github.com/angular/angular/commit/727f92f))
|
||||||
* **bazel:** do not use manifest paths for generated imports within compilation unit ([#35841](https://github.com/angular/angular/issues/35841)) ([9581658](https://github.com/angular/angular/commit/9581658))
|
* **bazel:** do not use manifest paths for generated imports within compilation unit ([#35841](https://github.com/angular/angular/issues/35841)) ([9581658](https://github.com/angular/angular/commit/9581658))
|
||||||
* **bazel:** ng_package rule creates incorrect UMD module exports ([#35792](https://github.com/angular/angular/issues/35792)) ([5c2a908](https://github.com/angular/angular/commit/5c2a908)), closes [angular/components#18652](https://github.com/angular/components/issues/18652)
|
* **bazel:** ng_package rule creates incorrect UMD module exports ([#35792](https://github.com/angular/angular/issues/35792)) ([5c2a908](https://github.com/angular/angular/commit/5c2a908)), closes [angular/components#18652](https://github.com/angular/components/issues/18652)
|
||||||
* **bazel:** prod server doesn't serve files in windows ([#35991](https://github.com/angular/angular/issues/35991)) ([96e3449](https://github.com/angular/angular/commit/96e3449))
|
* **bazel:** prod server doesn't serve files in windows ([#35991](https://github.com/angular/angular/issues/35991)) ([96e3449](https://github.com/angular/angular/commit/96e3449))
|
||||||
|
* **bazel:** spawn prod server using port 4200 ([#35160](https://github.com/angular/angular/issues/35160)) ([829f506](https://github.com/angular/angular/commit/829f506))
|
||||||
|
* **bazel:** update ibazel to 0.11.1 ([#35158](https://github.com/angular/angular/issues/35158)) ([4e6d237](https://github.com/angular/angular/commit/4e6d237))
|
||||||
* **bazel:** update several packages for better windows support ([#35991](https://github.com/angular/angular/issues/35991)) ([32f099a](https://github.com/angular/angular/commit/32f099a))
|
* **bazel:** update several packages for better windows support ([#35991](https://github.com/angular/angular/issues/35991)) ([32f099a](https://github.com/angular/angular/commit/32f099a))
|
||||||
* **bazel:** update typescript peer dependency range ([#36013](https://github.com/angular/angular/issues/36013)) ([5e3a898](https://github.com/angular/angular/commit/5e3a898))
|
* **bazel:** update typescript peer dependency range ([#36013](https://github.com/angular/angular/issues/36013)) ([5e3a898](https://github.com/angular/angular/commit/5e3a898))
|
||||||
* **common:** let `KeyValuePipe` accept type unions with `null` ([#36093](https://github.com/angular/angular/issues/36093)) ([407fa42](https://github.com/angular/angular/commit/407fa42)), closes [#35743](https://github.com/angular/angular/issues/35743)
|
* **common:** let `KeyValuePipe` accept type unions with `null` ([#36093](https://github.com/angular/angular/issues/36093)) ([407fa42](https://github.com/angular/angular/commit/407fa42)), closes [#35743](https://github.com/angular/angular/issues/35743)
|
||||||
@ -697,6 +667,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **compiler:** Propagate value span of ExpressionBinding to ParsedProperty ([#36133](https://github.com/angular/angular/issues/36133)) ([2ce5fa3](https://github.com/angular/angular/commit/2ce5fa3))
|
* **compiler:** Propagate value span of ExpressionBinding to ParsedProperty ([#36133](https://github.com/angular/angular/issues/36133)) ([2ce5fa3](https://github.com/angular/angular/commit/2ce5fa3))
|
||||||
* **compiler:** do not recurse to find static symbols of same module ([#35262](https://github.com/angular/angular/issues/35262)) ([e179c58](https://github.com/angular/angular/commit/e179c58))
|
* **compiler:** do not recurse to find static symbols of same module ([#35262](https://github.com/angular/angular/issues/35262)) ([e179c58](https://github.com/angular/angular/commit/e179c58))
|
||||||
* **compiler:** record correct end of expression ([#34690](https://github.com/angular/angular/issues/34690)) ([df890d7](https://github.com/angular/angular/commit/df890d7)), closes [#33477](https://github.com/angular/angular/issues/33477)
|
* **compiler:** record correct end of expression ([#34690](https://github.com/angular/angular/issues/34690)) ([df890d7](https://github.com/angular/angular/commit/df890d7)), closes [#33477](https://github.com/angular/angular/issues/33477)
|
||||||
|
* **compiler:** report errors for missing binding names ([#34595](https://github.com/angular/angular/issues/34595)) ([d13cab7](https://github.com/angular/angular/commit/d13cab7))
|
||||||
* **compiler:** support directive inputs with interpolations on `<ng-template>`s ([#35984](https://github.com/angular/angular/issues/35984)) ([79659ee](https://github.com/angular/angular/commit/79659ee)), closes [#35752](https://github.com/angular/angular/issues/35752)
|
* **compiler:** support directive inputs with interpolations on `<ng-template>`s ([#35984](https://github.com/angular/angular/issues/35984)) ([79659ee](https://github.com/angular/angular/commit/79659ee)), closes [#35752](https://github.com/angular/angular/issues/35752)
|
||||||
* **compiler:** support i18n attributes on `<ng-template>` tags ([#35681](https://github.com/angular/angular/issues/35681)) ([40da51f](https://github.com/angular/angular/commit/40da51f))
|
* **compiler:** support i18n attributes on `<ng-template>` tags ([#35681](https://github.com/angular/angular/issues/35681)) ([40da51f](https://github.com/angular/angular/commit/40da51f))
|
||||||
* **compiler:** type-checking error for duplicate variables in templates ([#35674](https://github.com/angular/angular/issues/35674)) ([2c41bb8](https://github.com/angular/angular/commit/2c41bb8)), closes [#35186](https://github.com/angular/angular/issues/35186)
|
* **compiler:** type-checking error for duplicate variables in templates ([#35674](https://github.com/angular/angular/issues/35674)) ([2c41bb8](https://github.com/angular/angular/commit/2c41bb8)), closes [#35186](https://github.com/angular/angular/issues/35186)
|
||||||
@ -734,13 +705,19 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **core:** workaround Terser inlining bug ([#36200](https://github.com/angular/angular/issues/36200)) ([f71d132](https://github.com/angular/angular/commit/f71d132))
|
* **core:** workaround Terser inlining bug ([#36200](https://github.com/angular/angular/issues/36200)) ([f71d132](https://github.com/angular/angular/commit/f71d132))
|
||||||
* **elements:** correctly handle setting inputs to `undefined` ([#36140](https://github.com/angular/angular/issues/36140)) ([e066bdd](https://github.com/angular/angular/commit/e066bdd))
|
* **elements:** correctly handle setting inputs to `undefined` ([#36140](https://github.com/angular/angular/issues/36140)) ([e066bdd](https://github.com/angular/angular/commit/e066bdd))
|
||||||
* **elements:** correctly set `SimpleChange#firstChange` for pre-existing inputs ([#36140](https://github.com/angular/angular/issues/36140)) ([447a600](https://github.com/angular/angular/commit/447a600)), closes [#36130](https://github.com/angular/angular/issues/36130)
|
* **elements:** correctly set `SimpleChange#firstChange` for pre-existing inputs ([#36140](https://github.com/angular/angular/issues/36140)) ([447a600](https://github.com/angular/angular/commit/447a600)), closes [#36130](https://github.com/angular/angular/issues/36130)
|
||||||
|
* **elements:** schematics fail with schema.json not found error ([#35211](https://github.com/angular/angular/issues/35211)) ([94d002b](https://github.com/angular/angular/commit/94d002b)), closes [#35154](https://github.com/angular/angular/issues/35154)
|
||||||
|
* **forms:** change Array.reduce usage to Array.forEach ([#35349](https://github.com/angular/angular/issues/35349)) ([554c2cb](https://github.com/angular/angular/commit/554c2cb))
|
||||||
* **ivy:** `LFrame` needs to release memory on `leaveView()` ([#35156](https://github.com/angular/angular/issues/35156)) ([b9b512f](https://github.com/angular/angular/commit/b9b512f)), closes [#35148](https://github.com/angular/angular/issues/35148)
|
* **ivy:** `LFrame` needs to release memory on `leaveView()` ([#35156](https://github.com/angular/angular/issues/35156)) ([b9b512f](https://github.com/angular/angular/commit/b9b512f)), closes [#35148](https://github.com/angular/angular/issues/35148)
|
||||||
* **ivy:** add attributes and classes to host elements based on selector ([#34481](https://github.com/angular/angular/issues/34481)) ([f95b8ce](https://github.com/angular/angular/commit/f95b8ce))
|
* **ivy:** add attributes and classes to host elements based on selector ([#34481](https://github.com/angular/angular/issues/34481)) ([f95b8ce](https://github.com/angular/angular/commit/f95b8ce))
|
||||||
|
* **ivy:** ensure module imports are instantiated before the module being declared ([#35172](https://github.com/angular/angular/issues/35172)) ([b6a3a73](https://github.com/angular/angular/commit/b6a3a73))
|
||||||
* **ivy:** error if directive with synthetic property binding is on same node as directive that injects ViewContainerRef ([#35343](https://github.com/angular/angular/issues/35343)) ([d6bc63f](https://github.com/angular/angular/commit/d6bc63f)), closes [#35342](https://github.com/angular/angular/issues/35342)
|
* **ivy:** error if directive with synthetic property binding is on same node as directive that injects ViewContainerRef ([#35343](https://github.com/angular/angular/issues/35343)) ([d6bc63f](https://github.com/angular/angular/commit/d6bc63f)), closes [#35342](https://github.com/angular/angular/issues/35342)
|
||||||
* **ivy:** narrow `NgIf` context variables in template type checker ([#35125](https://github.com/angular/angular/issues/35125)) ([40039d8](https://github.com/angular/angular/commit/40039d8)), closes [#34572](https://github.com/angular/angular/issues/34572)
|
* **ivy:** narrow `NgIf` context variables in template type checker ([#35125](https://github.com/angular/angular/issues/35125)) ([40039d8](https://github.com/angular/angular/commit/40039d8)), closes [#34572](https://github.com/angular/angular/issues/34572)
|
||||||
* **ivy:** queries should match elements inside ng-container with the descendants: false option ([#35384](https://github.com/angular/angular/issues/35384)) ([3f4e02b](https://github.com/angular/angular/commit/3f4e02b)), closes [#34768](https://github.com/angular/angular/issues/34768)
|
* **ivy:** queries should match elements inside ng-container with the descendants: false option ([#35384](https://github.com/angular/angular/issues/35384)) ([3f4e02b](https://github.com/angular/angular/commit/3f4e02b)), closes [#34768](https://github.com/angular/angular/issues/34768)
|
||||||
|
* **ivy:** repeat template guards to narrow types in event handlers ([#35193](https://github.com/angular/angular/issues/35193)) ([dea1b96](https://github.com/angular/angular/commit/dea1b96)), closes [#35073](https://github.com/angular/angular/issues/35073)
|
||||||
|
* **ivy:** set namespace for host elements of dynamically created components ([#35136](https://github.com/angular/angular/issues/35136)) ([480a4c3](https://github.com/angular/angular/commit/480a4c3))
|
||||||
* **ivy:** support dynamic query tokens in AOT mode ([#35307](https://github.com/angular/angular/issues/35307)) ([3e3a1ef](https://github.com/angular/angular/commit/3e3a1ef)), closes [#34267](https://github.com/angular/angular/issues/34267)
|
* **ivy:** support dynamic query tokens in AOT mode ([#35307](https://github.com/angular/angular/issues/35307)) ([3e3a1ef](https://github.com/angular/angular/commit/3e3a1ef)), closes [#34267](https://github.com/angular/angular/issues/34267)
|
||||||
* **ivy:** wrong context passed to ngOnDestroy when resolved multiple times ([#35249](https://github.com/angular/angular/issues/35249)) ([5fbfe69](https://github.com/angular/angular/commit/5fbfe69)), closes [#35167](https://github.com/angular/angular/issues/35167)
|
* **ivy:** wrong context passed to ngOnDestroy when resolved multiple times ([#35249](https://github.com/angular/angular/issues/35249)) ([5fbfe69](https://github.com/angular/angular/commit/5fbfe69)), closes [#35167](https://github.com/angular/angular/issues/35167)
|
||||||
|
* **language-service:** Suggest ? and ! operator on nullable receiver ([#35200](https://github.com/angular/angular/issues/35200)) ([3cc24a9](https://github.com/angular/angular/commit/3cc24a9))
|
||||||
* **language-service:** fix calculation of pipe spans ([#35986](https://github.com/angular/angular/issues/35986)) ([406419b](https://github.com/angular/angular/commit/406419b))
|
* **language-service:** fix calculation of pipe spans ([#35986](https://github.com/angular/angular/issues/35986)) ([406419b](https://github.com/angular/angular/commit/406419b))
|
||||||
* **language-service:** get the right 'ElementAst' in the nested HTML tag ([#35317](https://github.com/angular/angular/issues/35317)) ([8e354da](https://github.com/angular/angular/commit/8e354da))
|
* **language-service:** get the right 'ElementAst' in the nested HTML tag ([#35317](https://github.com/angular/angular/issues/35317)) ([8e354da](https://github.com/angular/angular/commit/8e354da))
|
||||||
* **language-service:** infer $implicit value for ngIf template contexts ([#35941](https://github.com/angular/angular/issues/35941)) ([18b1bd4](https://github.com/angular/angular/commit/18b1bd4))
|
* **language-service:** infer $implicit value for ngIf template contexts ([#35941](https://github.com/angular/angular/issues/35941)) ([18b1bd4](https://github.com/angular/angular/commit/18b1bd4))
|
||||||
@ -765,6 +742,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **ngcc:** correctly detect outer aliased class identifiers in ES5 ([#35527](https://github.com/angular/angular/issues/35527)) ([fde8915](https://github.com/angular/angular/commit/fde8915)), closes [#35399](https://github.com/angular/angular/issues/35399)
|
* **ngcc:** correctly detect outer aliased class identifiers in ES5 ([#35527](https://github.com/angular/angular/issues/35527)) ([fde8915](https://github.com/angular/angular/commit/fde8915)), closes [#35399](https://github.com/angular/angular/issues/35399)
|
||||||
* **ngcc:** do not crash on entry-point that fails to compile ([#36083](https://github.com/angular/angular/issues/36083)) ([ff665b9](https://github.com/angular/angular/commit/ff665b9))
|
* **ngcc:** do not crash on entry-point that fails to compile ([#36083](https://github.com/angular/angular/issues/36083)) ([ff665b9](https://github.com/angular/angular/commit/ff665b9))
|
||||||
* **ngcc:** do not crash on overlapping entry-points ([#36083](https://github.com/angular/angular/issues/36083)) ([c9f554c](https://github.com/angular/angular/commit/c9f554c))
|
* **ngcc:** do not crash on overlapping entry-points ([#36083](https://github.com/angular/angular/issues/36083)) ([c9f554c](https://github.com/angular/angular/commit/c9f554c))
|
||||||
|
* **ngcc:** ensure that path-mapped secondary entry-points are processed correctly ([#35227](https://github.com/angular/angular/issues/35227)) ([c3c1140](https://github.com/angular/angular/commit/c3c1140)), closes [#35188](https://github.com/angular/angular/issues/35188)
|
||||||
* **ngcc:** handle imports in dts files when processing CommonJS ([#35191](https://github.com/angular/angular/issues/35191)) ([b6e8847](https://github.com/angular/angular/commit/b6e8847)), closes [#34356](https://github.com/angular/angular/issues/34356)
|
* **ngcc:** handle imports in dts files when processing CommonJS ([#35191](https://github.com/angular/angular/issues/35191)) ([b6e8847](https://github.com/angular/angular/commit/b6e8847)), closes [#34356](https://github.com/angular/angular/issues/34356)
|
||||||
* **ngcc:** handle mappings outside the content when flattening source-maps ([#35718](https://github.com/angular/angular/issues/35718)) ([73cf7d5](https://github.com/angular/angular/commit/73cf7d5)), closes [#35709](https://github.com/angular/angular/issues/35709)
|
* **ngcc:** handle mappings outside the content when flattening source-maps ([#35718](https://github.com/angular/angular/issues/35718)) ([73cf7d5](https://github.com/angular/angular/commit/73cf7d5)), closes [#35709](https://github.com/angular/angular/issues/35709)
|
||||||
* **ngcc:** handle missing sources when flattening source-maps ([#35718](https://github.com/angular/angular/issues/35718)) ([72c4fda](https://github.com/angular/angular/commit/72c4fda)), closes [#35709](https://github.com/angular/angular/issues/35709)
|
* **ngcc:** handle missing sources when flattening source-maps ([#35718](https://github.com/angular/angular/issues/35718)) ([72c4fda](https://github.com/angular/angular/commit/72c4fda)), closes [#35709](https://github.com/angular/angular/issues/35709)
|
||||||
@ -1022,7 +1000,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **compiler-cli:** require node 10 as runtime engine ([#34722](https://github.com/angular/angular/issues/34722)) ([7b77b3d](https://github.com/angular/angular/commit/7b77b3d))
|
* **compiler-cli:** require node 10 as runtime engine ([#34722](https://github.com/angular/angular/issues/34722)) ([7b77b3d](https://github.com/angular/angular/commit/7b77b3d))
|
||||||
* **language-service:** specific suggestions for template context diags ([#34751](https://github.com/angular/angular/issues/34751)) ([cc7fca4](https://github.com/angular/angular/commit/cc7fca4))
|
* **language-service:** specific suggestions for template context diags ([#34751](https://github.com/angular/angular/issues/34751)) ([cc7fca4](https://github.com/angular/angular/commit/cc7fca4))
|
||||||
* **language-service:** support multiple symbol definitions ([#34782](https://github.com/angular/angular/issues/34782)) ([2f2396c](https://github.com/angular/angular/commit/2f2396c))
|
* **language-service:** support multiple symbol definitions ([#34782](https://github.com/angular/angular/issues/34782)) ([2f2396c](https://github.com/angular/angular/commit/2f2396c))
|
||||||
* **ngcc:** lock ngcc when processing ([#34722](https://github.com/angular/angular/issues/34722)) ([6dd51f1](https://github.com/angular/angular/commit/6dd51f1)), closes [/github.com/angular/angular/issues/32431#issuecomment-571825781](https://github.com/angular/angular/issues/32431/issues/issuecomment-571825781)
|
* **ngcc:** lock ngcc when processing ([#34722](https://github.com/angular/angular/issues/34722)) ([6dd51f1](https://github.com/angular/angular/commit/6dd51f1)), closes [32431#issuecomment-571825781](https://github.com/angular/angular/issues/32431#issuecomment-571825781)
|
||||||
* work around 'noImplicityAny' incompatibility due to ts3.7 update ([#34798](https://github.com/angular/angular/issues/34798)) ([251d548](https://github.com/angular/angular/commit/251d548))
|
* work around 'noImplicityAny' incompatibility due to ts3.7 update ([#34798](https://github.com/angular/angular/issues/34798)) ([251d548](https://github.com/angular/angular/commit/251d548))
|
||||||
* **animations:** not waiting for child animations to finish when removing parent in Ivy ([#34702](https://github.com/angular/angular/issues/34702)) ([92c17fe](https://github.com/angular/angular/commit/92c17fe)), closes [#33597](https://github.com/angular/angular/issues/33597)
|
* **animations:** not waiting for child animations to finish when removing parent in Ivy ([#34702](https://github.com/angular/angular/issues/34702)) ([92c17fe](https://github.com/angular/angular/commit/92c17fe)), closes [#33597](https://github.com/angular/angular/issues/33597)
|
||||||
* **common:** ensure diffing in ngStyle/ngClass correctly emits value changes ([#34307](https://github.com/angular/angular/issues/34307)) ([93a035f](https://github.com/angular/angular/commit/93a035f)), closes [#34336](https://github.com/angular/angular/issues/34336) [#34444](https://github.com/angular/angular/issues/34444)
|
* **common:** ensure diffing in ngStyle/ngClass correctly emits value changes ([#34307](https://github.com/angular/angular/issues/34307)) ([93a035f](https://github.com/angular/angular/commit/93a035f)), closes [#34336](https://github.com/angular/angular/issues/34336) [#34444](https://github.com/angular/angular/issues/34444)
|
||||||
@ -1153,7 +1131,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **ngcc:** do not output duplicate ɵprov properties ([#34085](https://github.com/angular/angular/issues/34085)) ([5a8d25d](https://github.com/angular/angular/commit/5a8d25d))
|
* **ngcc:** do not output duplicate ɵprov properties ([#34085](https://github.com/angular/angular/issues/34085)) ([5a8d25d](https://github.com/angular/angular/commit/5a8d25d))
|
||||||
* **ngcc:** render localized strings when in ES5 format ([#33857](https://github.com/angular/angular/issues/33857)) ([c6695fa](https://github.com/angular/angular/commit/c6695fa))
|
* **ngcc:** render localized strings when in ES5 format ([#33857](https://github.com/angular/angular/issues/33857)) ([c6695fa](https://github.com/angular/angular/commit/c6695fa))
|
||||||
* **ngcc:** render UMD global imports correctly ([#34012](https://github.com/angular/angular/issues/34012)) ([83989b8](https://github.com/angular/angular/commit/83989b8))
|
* **ngcc:** render UMD global imports correctly ([#34012](https://github.com/angular/angular/issues/34012)) ([83989b8](https://github.com/angular/angular/commit/83989b8))
|
||||||
* **ngcc:** report errors from `analyze` and `resolve` processing ([#33964](https://github.com/angular/angular/issues/33964)) ([ca5d772](https://github.com/angular/angular/commit/ca5d772)), closes [/github.com/angular/angular/issues/33685#issuecomment-557091719](https://github.com/angular/angular/issues/33685/issues/issuecomment-557091719)
|
* **ngcc:** report errors from `analyze` and `resolve` processing ([#33964](https://github.com/angular/angular/issues/33964)) ([ca5d772](https://github.com/angular/angular/commit/ca5d772)), closes [33685#issuecomment-557091719](https://github.com/angular/angular/issues/33685#issuecomment-557091719)
|
||||||
* **router:** make routerLinkActive work with query params which contain arrays ([#22666](https://github.com/angular/angular/issues/22666)) ([f1bf5b2](https://github.com/angular/angular/commit/f1bf5b2)), closes [#22223](https://github.com/angular/angular/issues/22223)
|
* **router:** make routerLinkActive work with query params which contain arrays ([#22666](https://github.com/angular/angular/issues/22666)) ([f1bf5b2](https://github.com/angular/angular/commit/f1bf5b2)), closes [#22223](https://github.com/angular/angular/issues/22223)
|
||||||
* **service-worker:** allow creating post api requests after cache failure ([#33930](https://github.com/angular/angular/issues/33930)) ([63c9123](https://github.com/angular/angular/commit/63c9123)), closes [#33793](https://github.com/angular/angular/issues/33793)
|
* **service-worker:** allow creating post api requests after cache failure ([#33930](https://github.com/angular/angular/issues/33930)) ([63c9123](https://github.com/angular/angular/commit/63c9123)), closes [#33793](https://github.com/angular/angular/issues/33793)
|
||||||
* **service-worker:** throw when using the unsupported `versionedFiles` option in config ([#33903](https://github.com/angular/angular/issues/33903)) ([250e6fd](https://github.com/angular/angular/commit/250e6fd))
|
* **service-worker:** throw when using the unsupported `versionedFiles` option in config ([#33903](https://github.com/angular/angular/issues/33903)) ([250e6fd](https://github.com/angular/angular/commit/250e6fd))
|
||||||
@ -1232,7 +1210,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **language-service:** Should not crash if expr ends unexpectedly ([#33524](https://github.com/angular/angular/issues/33524)) ([9ebac71](https://github.com/angular/angular/commit/9ebac71))
|
* **language-service:** Should not crash if expr ends unexpectedly ([#33524](https://github.com/angular/angular/issues/33524)) ([9ebac71](https://github.com/angular/angular/commit/9ebac71))
|
||||||
* **ngcc:** handle new `__spreadArrays` tslib helper ([#33617](https://github.com/angular/angular/issues/33617)) ([d749dd3](https://github.com/angular/angular/commit/d749dd3)), closes [#33614](https://github.com/angular/angular/issues/33614)
|
* **ngcc:** handle new `__spreadArrays` tslib helper ([#33617](https://github.com/angular/angular/issues/33617)) ([d749dd3](https://github.com/angular/angular/commit/d749dd3)), closes [#33614](https://github.com/angular/angular/issues/33614)
|
||||||
* **ngcc:** override `getInternalNameOfClass()` and `getAdjacentNameOfClass()` for ES5 ([#33533](https://github.com/angular/angular/issues/33533)) ([93a23b9](https://github.com/angular/angular/commit/93a23b9))
|
* **ngcc:** override `getInternalNameOfClass()` and `getAdjacentNameOfClass()` for ES5 ([#33533](https://github.com/angular/angular/issues/33533)) ([93a23b9](https://github.com/angular/angular/commit/93a23b9))
|
||||||
* **ngcc:** render adjacent statements after static properties ([#33630](https://github.com/angular/angular/issues/33630)) ([fe12d0d](https://github.com/angular/angular/commit/fe12d0d)), closes [/github.com/angular/angular/pull/33337#issuecomment-545487737](https://github.com/angular/angular/pull/33337/issues/issuecomment-545487737)
|
* **ngcc:** render adjacent statements after static properties ([#33630](https://github.com/angular/angular/issues/33630)) ([fe12d0d](https://github.com/angular/angular/commit/fe12d0d)), closes [/github.com/angular/angular/pull/33337#issuecomment-545487737](https://github.com/angular/angular/pull/33337#issuecomment-545487737)
|
||||||
* **ngcc:** render new definitions using the inner name of the class ([#33533](https://github.com/angular/angular/issues/33533)) ([85298e3](https://github.com/angular/angular/commit/85298e3))
|
* **ngcc:** render new definitions using the inner name of the class ([#33533](https://github.com/angular/angular/issues/33533)) ([85298e3](https://github.com/angular/angular/commit/85298e3))
|
||||||
* **service-worker:** ensure initialization before handling messages ([#32525](https://github.com/angular/angular/issues/32525)) ([72eba77](https://github.com/angular/angular/commit/72eba77)), closes [#25611](https://github.com/angular/angular/issues/25611)
|
* **service-worker:** ensure initialization before handling messages ([#32525](https://github.com/angular/angular/issues/32525)) ([72eba77](https://github.com/angular/angular/commit/72eba77)), closes [#25611](https://github.com/angular/angular/issues/25611)
|
||||||
* **compiler:** i18n - ignore `alt-trans` tags in XLIFF 1.2 ([#33450](https://github.com/angular/angular/issues/33450)) ([936700a](https://github.com/angular/angular/commit/936700a)), closes [#33161](https://github.com/angular/angular/issues/33161)
|
* **compiler:** i18n - ignore `alt-trans` tags in XLIFF 1.2 ([#33450](https://github.com/angular/angular/issues/33450)) ([936700a](https://github.com/angular/angular/commit/936700a)), closes [#33161](https://github.com/angular/angular/issues/33161)
|
||||||
@ -1262,7 +1240,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **language-service:** Add directive selectors & banana-in-a-box to completions ([#33311](https://github.com/angular/angular/issues/33311)) ([49eec5d](https://github.com/angular/angular/commit/49eec5d))
|
* **language-service:** Add directive selectors & banana-in-a-box to completions ([#33311](https://github.com/angular/angular/issues/33311)) ([49eec5d](https://github.com/angular/angular/commit/49eec5d))
|
||||||
* **language-service:** Add global symbol for $any() ([#33245](https://github.com/angular/angular/issues/33245)) ([3f257e9](https://github.com/angular/angular/commit/3f257e9))
|
* **language-service:** Add global symbol for $any() ([#33245](https://github.com/angular/angular/issues/33245)) ([3f257e9](https://github.com/angular/angular/commit/3f257e9))
|
||||||
* **language-service:** Preserve CRLF in templates for language-service ([#33241](https://github.com/angular/angular/issues/33241)) ([65a0d2b](https://github.com/angular/angular/commit/65a0d2b))
|
* **language-service:** Preserve CRLF in templates for language-service ([#33241](https://github.com/angular/angular/issues/33241)) ([65a0d2b](https://github.com/angular/angular/commit/65a0d2b))
|
||||||
* **ngcc:** do not fail when multiple workers try to create the same directory ([#33237](https://github.com/angular/angular/issues/33237)) ([8017229](https://github.com/angular/angular/commit/8017229)), closes [/github.com/angular/angular/pull/33049#issuecomment-540485703](https://github.com/angular/angular/pull/33049/issues/issuecomment-540485703)
|
* **ngcc:** do not fail when multiple workers try to create the same directory ([#33237](https://github.com/angular/angular/issues/33237)) ([8017229](https://github.com/angular/angular/commit/8017229)), closes [/github.com/angular/angular/pull/33049#issuecomment-540485703](https://github.com/angular/angular/pull/33049#issuecomment-540485703)
|
||||||
* **bazel:** Remove angular devkit and restore ngc postinstall ([#32946](https://github.com/angular/angular/issues/32946)) ([f036684](https://github.com/angular/angular/commit/f036684))
|
* **bazel:** Remove angular devkit and restore ngc postinstall ([#32946](https://github.com/angular/angular/issues/32946)) ([f036684](https://github.com/angular/angular/commit/f036684))
|
||||||
* **common:** remove deprecated support for intl API ([#29250](https://github.com/angular/angular/issues/29250)) ([9e7668f](https://github.com/angular/angular/commit/9e7668f)), closes [#18284](https://github.com/angular/angular/issues/18284)
|
* **common:** remove deprecated support for intl API ([#29250](https://github.com/angular/angular/issues/29250)) ([9e7668f](https://github.com/angular/angular/commit/9e7668f)), closes [#18284](https://github.com/angular/angular/issues/18284)
|
||||||
* **compiler:** absolute source span for template attribute expressions ([#33189](https://github.com/angular/angular/issues/33189)) ([fd4fed1](https://github.com/angular/angular/commit/fd4fed1))
|
* **compiler:** absolute source span for template attribute expressions ([#33189](https://github.com/angular/angular/issues/33189)) ([fd4fed1](https://github.com/angular/angular/commit/fd4fed1))
|
||||||
@ -1319,7 +1297,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **language-service:** Turn on strict mode for test project ([#32783](https://github.com/angular/angular/issues/32783)) ([28358b6](https://github.com/angular/angular/commit/28358b6))
|
* **language-service:** Turn on strict mode for test project ([#32783](https://github.com/angular/angular/issues/32783)) ([28358b6](https://github.com/angular/angular/commit/28358b6))
|
||||||
* **ngcc:** ensure private exports are added for `ModuleWithProviders` ([#32902](https://github.com/angular/angular/issues/32902)) ([002a97d](https://github.com/angular/angular/commit/002a97d))
|
* **ngcc:** ensure private exports are added for `ModuleWithProviders` ([#32902](https://github.com/angular/angular/issues/32902)) ([002a97d](https://github.com/angular/angular/commit/002a97d))
|
||||||
* **ngcc:** handle presence of both `ctorParameters` and `__decorate` ([#32901](https://github.com/angular/angular/issues/32901)) ([747f0cf](https://github.com/angular/angular/commit/747f0cf))
|
* **ngcc:** handle presence of both `ctorParameters` and `__decorate` ([#32901](https://github.com/angular/angular/issues/32901)) ([747f0cf](https://github.com/angular/angular/commit/747f0cf))
|
||||||
* **ngcc:** make the build-marker error more clear ([#32712](https://github.com/angular/angular/issues/32712)) ([0ea4875](https://github.com/angular/angular/commit/0ea4875)), closes [/github.com/angular/angular/issues/31354#issuecomment-532080537](https://github.com/angular/angular/issues/31354/issues/issuecomment-532080537)
|
* **ngcc:** make the build-marker error more clear ([#32712](https://github.com/angular/angular/issues/32712)) ([0ea4875](https://github.com/angular/angular/commit/0ea4875)), closes [31354#issuecomment-532080537](https://github.com/angular/angular/issues/31354#issuecomment-532080537)
|
||||||
* **upgrade:** fix AngularJsUrlCodec to support Safari ([#32959](https://github.com/angular/angular/issues/32959)) ([39e8ceb](https://github.com/angular/angular/commit/39e8ceb))
|
* **upgrade:** fix AngularJsUrlCodec to support Safari ([#32959](https://github.com/angular/angular/issues/32959)) ([39e8ceb](https://github.com/angular/angular/commit/39e8ceb))
|
||||||
* **ivy:** ensure `window.ng.getDebugNode` returns debug info for component elements ([#32780](https://github.com/angular/angular/issues/32780)) ([5651fa3](https://github.com/angular/angular/commit/5651fa3))
|
* **ivy:** ensure `window.ng.getDebugNode` returns debug info for component elements ([#32780](https://github.com/angular/angular/issues/32780)) ([5651fa3](https://github.com/angular/angular/commit/5651fa3))
|
||||||
* **ivy:** ensure multiple map-based bindings do not skip intermediate values ([#32774](https://github.com/angular/angular/issues/32774)) ([86fd571](https://github.com/angular/angular/commit/86fd571))
|
* **ivy:** ensure multiple map-based bindings do not skip intermediate values ([#32774](https://github.com/angular/angular/issues/32774)) ([86fd571](https://github.com/angular/angular/commit/86fd571))
|
||||||
@ -1428,7 +1406,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **ivy:** graceful evaluation of unknown or invalid expressions ([#33453](https://github.com/angular/angular/issues/33453)) ([ce30888](https://github.com/angular/angular/commit/ce30888))
|
* **ivy:** graceful evaluation of unknown or invalid expressions ([#33453](https://github.com/angular/angular/issues/33453)) ([ce30888](https://github.com/angular/angular/commit/ce30888))
|
||||||
* **ivy:** implement unknown element detection in jit mode ([#33419](https://github.com/angular/angular/issues/33419)) ([c83f501](https://github.com/angular/angular/commit/c83f501))
|
* **ivy:** implement unknown element detection in jit mode ([#33419](https://github.com/angular/angular/issues/33419)) ([c83f501](https://github.com/angular/angular/commit/c83f501))
|
||||||
* add a flag in bootstrap to enable coalesce event change detection to improve performance ([#30533](https://github.com/angular/angular/issues/30533)) ([44623a1](https://github.com/angular/angular/commit/44623a1))
|
* add a flag in bootstrap to enable coalesce event change detection to improve performance ([#30533](https://github.com/angular/angular/issues/30533)) ([44623a1](https://github.com/angular/angular/commit/44623a1))
|
||||||
* **bazel:** update [@bazel](https://github.com/bazel)/schematics to Bazel 1.0.0 ([#33476](https://github.com/angular/angular/issues/33476)) ([540d104](https://github.com/angular/angular/commit/540d104)), closes [/github.com/angular/angular/pull/33367#issuecomment-547643246](https://github.com/angular/angular/pull/33367/issues/issuecomment-547643246)
|
* **bazel:** update [@bazel](https://github.com/bazel)/schematics to Bazel 1.0.0 ([#33476](https://github.com/angular/angular/issues/33476)) ([540d104](https://github.com/angular/angular/commit/540d104)), closes [/github.com/angular/angular/pull/33367#issuecomment-547643246](https://github.com/angular/angular/pull/33367#issuecomment-547643246)
|
||||||
* **bazel:** update bazel-schematics to use Ivy and new rollup_bundle ([#33435](https://github.com/angular/angular/issues/33435)) ([bf913cc](https://github.com/angular/angular/commit/bf913cc))
|
* **bazel:** update bazel-schematics to use Ivy and new rollup_bundle ([#33435](https://github.com/angular/angular/issues/33435)) ([bf913cc](https://github.com/angular/angular/commit/bf913cc))
|
||||||
* **ivy:** i18n - support inlining of XTB formatted translation files ([#33444](https://github.com/angular/angular/issues/33444)) ([2c623fd](https://github.com/angular/angular/commit/2c623fd))
|
* **ivy:** i18n - support inlining of XTB formatted translation files ([#33444](https://github.com/angular/angular/issues/33444)) ([2c623fd](https://github.com/angular/angular/commit/2c623fd))
|
||||||
* **language-service:** add support for text replacement ([#33091](https://github.com/angular/angular/issues/33091)) ([da4eb91](https://github.com/angular/angular/commit/da4eb91))
|
* **language-service:** add support for text replacement ([#33091](https://github.com/angular/angular/issues/33091)) ([da4eb91](https://github.com/angular/angular/commit/da4eb91))
|
||||||
@ -1470,7 +1448,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **ivy:** i18n - implement compile-time inlining ([#32881](https://github.com/angular/angular/issues/32881)) ([2cdb3a0](https://github.com/angular/angular/commit/2cdb3a0))
|
* **ivy:** i18n - implement compile-time inlining ([#32881](https://github.com/angular/angular/issues/32881)) ([2cdb3a0](https://github.com/angular/angular/commit/2cdb3a0))
|
||||||
* **ivy:** i18n - render legacy message ids in `$localize` if requested ([#32937](https://github.com/angular/angular/issues/32937)) ([bcbf3e4](https://github.com/angular/angular/commit/bcbf3e4))
|
* **ivy:** i18n - render legacy message ids in `$localize` if requested ([#32937](https://github.com/angular/angular/issues/32937)) ([bcbf3e4](https://github.com/angular/angular/commit/bcbf3e4))
|
||||||
* **language-service:** module definitions on directive hover ([#32763](https://github.com/angular/angular/issues/32763)) ([0d186dd](https://github.com/angular/angular/commit/0d186dd)), closes [#32565](https://github.com/angular/angular/issues/32565)
|
* **language-service:** module definitions on directive hover ([#32763](https://github.com/angular/angular/issues/32763)) ([0d186dd](https://github.com/angular/angular/commit/0d186dd)), closes [#32565](https://github.com/angular/angular/issues/32565)
|
||||||
* **ngcc:** expose `--create-ivy-entry-points` option on ivy-ngcc ([#33049](https://github.com/angular/angular/issues/33049)) ([b2b917d](https://github.com/angular/angular/commit/b2b917d)), closes [/github.com/angular/angular/pull/32999#issuecomment-539937368](https://github.com/angular/angular/pull/32999/issues/issuecomment-539937368)
|
* **ngcc:** expose `--create-ivy-entry-points` option on ivy-ngcc ([#33049](https://github.com/angular/angular/issues/33049)) ([b2b917d](https://github.com/angular/angular/commit/b2b917d)), closes [/github.com/angular/angular/pull/32999#issuecomment-539937368](https://github.com/angular/angular/pull/32999#issuecomment-539937368)
|
||||||
* update rxjs peerDependencies minimum requirment to 6.5.3 ([#32812](https://github.com/angular/angular/issues/32812)) ([66658c4](https://github.com/angular/angular/commit/66658c4))
|
* update rxjs peerDependencies minimum requirment to 6.5.3 ([#32812](https://github.com/angular/angular/issues/32812)) ([66658c4](https://github.com/angular/angular/commit/66658c4))
|
||||||
* **ivy:** support ng-add in localize package ([#32791](https://github.com/angular/angular/issues/32791)) ([e41cbfb](https://github.com/angular/angular/commit/e41cbfb))
|
* **ivy:** support ng-add in localize package ([#32791](https://github.com/angular/angular/issues/32791)) ([e41cbfb](https://github.com/angular/angular/commit/e41cbfb))
|
||||||
* **language-service:** allow retreiving synchronized analyzed NgModules ([#32779](https://github.com/angular/angular/issues/32779)) ([98feee7](https://github.com/angular/angular/commit/98feee7))
|
* **language-service:** allow retreiving synchronized analyzed NgModules ([#32779](https://github.com/angular/angular/issues/32779)) ([98feee7](https://github.com/angular/angular/commit/98feee7))
|
||||||
@ -1849,6 +1827,7 @@ This release contains various API docs improvements.
|
|||||||
* **language-service:** Eagarly initialize data members ([#31577](https://github.com/angular/angular/issues/31577)) ([0110de2](https://github.com/angular/angular/commit/0110de2))
|
* **language-service:** Eagarly initialize data members ([#31577](https://github.com/angular/angular/issues/31577)) ([0110de2](https://github.com/angular/angular/commit/0110de2))
|
||||||
* **bazel:** revert location of xi18n outputs to bazel-genfiles ([#31410](https://github.com/angular/angular/issues/31410)) ([1d3e227](https://github.com/angular/angular/commit/1d3e227))
|
* **bazel:** revert location of xi18n outputs to bazel-genfiles ([#31410](https://github.com/angular/angular/issues/31410)) ([1d3e227](https://github.com/angular/angular/commit/1d3e227))
|
||||||
* **compiler:** give ASTWithSource its own visit method ([#31347](https://github.com/angular/angular/issues/31347)) ([6aaca21](https://github.com/angular/angular/commit/6aaca21))
|
* **compiler:** give ASTWithSource its own visit method ([#31347](https://github.com/angular/angular/issues/31347)) ([6aaca21](https://github.com/angular/angular/commit/6aaca21))
|
||||||
|
* **core:** handle `undefined` meta in `injectArgs` ([#31333](https://github.com/angular/angular/issues/31333)) ([80ccd6c](https://github.com/angular/angular/commit/80ccd6c)), closes [CLI #14888](https://github.com/angular/angular-cli/issues/14888)
|
||||||
* **service-worker:** cache opaque responses in data groups with `freshness` strategy ([#30977](https://github.com/angular/angular/issues/30977)) ([d7be38f](https://github.com/angular/angular/commit/d7be38f)), closes [#30968](https://github.com/angular/angular/issues/30968)
|
* **service-worker:** cache opaque responses in data groups with `freshness` strategy ([#30977](https://github.com/angular/angular/issues/30977)) ([d7be38f](https://github.com/angular/angular/commit/d7be38f)), closes [#30968](https://github.com/angular/angular/issues/30968)
|
||||||
* **service-worker:** cache opaque responses when requests exceeds timeout threshold ([#30977](https://github.com/angular/angular/issues/30977)) ([93abc35](https://github.com/angular/angular/commit/93abc35))
|
* **service-worker:** cache opaque responses when requests exceeds timeout threshold ([#30977](https://github.com/angular/angular/issues/30977)) ([93abc35](https://github.com/angular/angular/commit/93abc35))
|
||||||
|
|
||||||
@ -1878,6 +1857,7 @@ This release contains various API docs improvements.
|
|||||||
|
|
||||||
* use the correct WTF array to iterate over ([#31208](https://github.com/angular/angular/issues/31208)) ([4aed480](https://github.com/angular/angular/commit/4aed480))
|
* use the correct WTF array to iterate over ([#31208](https://github.com/angular/angular/issues/31208)) ([4aed480](https://github.com/angular/angular/commit/4aed480))
|
||||||
* **compiler-cli:** Return original sourceFile instead of redirected sourceFile from getSourceFile ([#26036](https://github.com/angular/angular/issues/26036)) ([13dbb98](https://github.com/angular/angular/commit/13dbb98)), closes [#22524](https://github.com/angular/angular/issues/22524)
|
* **compiler-cli:** Return original sourceFile instead of redirected sourceFile from getSourceFile ([#26036](https://github.com/angular/angular/issues/26036)) ([13dbb98](https://github.com/angular/angular/commit/13dbb98)), closes [#22524](https://github.com/angular/angular/issues/22524)
|
||||||
|
* **core:** export provider interfaces that are part of the public API types ([#31377](https://github.com/angular/angular/issues/31377)) ([bebf089](https://github.com/angular/angular/commit/bebf089)), closes [/github.com/angular/angular/pull/31377#discussion_r299254408](https://github.com/angular/angular/pull/31377/issues/discussion_r299254408) [/github.com/angular/angular/blob/9e34670b2/packages/core/src/di/interface/provider.ts#L365-L366](https://github.com/angular/angular/blob/9e34670b2/packages/core/src/di/interface/provider.ts/issues/L365-L366) [/github.com/angular/angular/blob/9e34670b2/packages/core/src/di/interface/provider.ts#L283-L284](https://github.com/angular/angular/blob/9e34670b2/packages/core/src/di/interface/provider.ts/issues/L283-L284) [/github.com/angular/angular/blob/9e34670b2/packages/core/src/di/index.ts#L23](https://github.com/angular/angular/blob/9e34670b2/packages/core/src/di/index.ts/issues/L23)
|
||||||
|
|
||||||
|
|
||||||
<a name="8.1.1"></a>
|
<a name="8.1.1"></a>
|
||||||
@ -2055,6 +2035,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
### Features
|
### Features
|
||||||
|
|
||||||
* add support for TypeScript 3.4 (and drop older versions) ([#29372](https://github.com/angular/angular/issues/29372)) ([ef85336](https://github.com/angular/angular/commit/ef85336))
|
* add support for TypeScript 3.4 (and drop older versions) ([#29372](https://github.com/angular/angular/issues/29372)) ([ef85336](https://github.com/angular/angular/commit/ef85336))
|
||||||
|
* **common:** add ability to watch for AngularJS URL updates through `onUrlChange` hook ([#30466](https://github.com/angular/angular/issues/30466)) ([8022d36](https://github.com/angular/angular/commit/8022d36))
|
||||||
* **common:** stricter types for `SlicePipe` ([#30156](https://github.com/angular/angular/issues/30156)) ([722b2fa](https://github.com/angular/angular/commit/722b2fa))
|
* **common:** stricter types for `SlicePipe` ([#30156](https://github.com/angular/angular/issues/30156)) ([722b2fa](https://github.com/angular/angular/commit/722b2fa))
|
||||||
* **bazel:** use `rbe_autoconfig()` and new container ([#29336](https://github.com/angular/angular/issues/29336)) ([e562acc](https://github.com/angular/angular/commit/e562acc))
|
* **bazel:** use `rbe_autoconfig()` and new container ([#29336](https://github.com/angular/angular/issues/29336)) ([e562acc](https://github.com/angular/angular/commit/e562acc))
|
||||||
* **common:** add @angular/common/upgrade package for `$location`-related APIs ([#30055](https://github.com/angular/angular/issues/30055)) ([152d99e](https://github.com/angular/angular/commit/152d99e))
|
* **common:** add @angular/common/upgrade package for `$location`-related APIs ([#30055](https://github.com/angular/angular/issues/30055)) ([152d99e](https://github.com/angular/angular/commit/152d99e))
|
||||||
@ -2171,6 +2152,8 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **bazel:** use `//:tsconfig.json` as the default for `ng_module` ([#29670](https://github.com/angular/angular/issues/29670)) ([b14537a](https://github.com/angular/angular/commit/b14537a))
|
* **bazel:** use `//:tsconfig.json` as the default for `ng_module` ([#29670](https://github.com/angular/angular/issues/29670)) ([b14537a](https://github.com/angular/angular/commit/b14537a))
|
||||||
* **compiler-cli:** ngcc - cope with processing entry-points multiple times ([#29657](https://github.com/angular/angular/issues/29657)) ([6b39c9c](https://github.com/angular/angular/commit/6b39c9c))
|
* **compiler-cli:** ngcc - cope with processing entry-points multiple times ([#29657](https://github.com/angular/angular/issues/29657)) ([6b39c9c](https://github.com/angular/angular/commit/6b39c9c))
|
||||||
* **core:** static-query schematic should detect static queries in getters. ([#29609](https://github.com/angular/angular/issues/29609)) ([33016b8](https://github.com/angular/angular/commit/33016b8))
|
* **core:** static-query schematic should detect static queries in getters. ([#29609](https://github.com/angular/angular/issues/29609)) ([33016b8](https://github.com/angular/angular/commit/33016b8))
|
||||||
|
* **common:** escape query selector used when anchor scrolling ([#29577](https://github.com/angular/angular/issues/29577)) ([7671c73](https://github.com/angular/angular/commit/7671c73)), closes [#28193](https://github.com/angular/angular/issues/28193)
|
||||||
|
* **router:** adjust setting navigationTransition when a new navigation cancels an existing one ([#29636](https://github.com/angular/angular/issues/29636)) ([e884c0c](https://github.com/angular/angular/commit/e884c0c)), closes [#29389](https://github.com/angular/angular/issues/29389) [#29590](https://github.com/angular/angular/issues/29590)
|
||||||
* **bazel:** allow `ng_module` users to set `createExternalSymbolFactoryReexports` ([#29459](https://github.com/angular/angular/issues/29459)) ([21be0fb](https://github.com/angular/angular/commit/21be0fb))
|
* **bazel:** allow `ng_module` users to set `createExternalSymbolFactoryReexports` ([#29459](https://github.com/angular/angular/issues/29459)) ([21be0fb](https://github.com/angular/angular/commit/21be0fb))
|
||||||
* **bazel:** workaround problem reading summary files from node_modules ([#29459](https://github.com/angular/angular/issues/29459)) ([769d960](https://github.com/angular/angular/commit/769d960))
|
* **bazel:** workaround problem reading summary files from node_modules ([#29459](https://github.com/angular/angular/issues/29459)) ([769d960](https://github.com/angular/angular/commit/769d960))
|
||||||
* **compiler:** inherit param types when class has a constructor which takes no declared parameters and delegates up ([#29232](https://github.com/angular/angular/issues/29232)) ([0007564](https://github.com/angular/angular/commit/0007564))
|
* **compiler:** inherit param types when class has a constructor which takes no declared parameters and delegates up ([#29232](https://github.com/angular/angular/issues/29232)) ([0007564](https://github.com/angular/angular/commit/0007564))
|
||||||
@ -2197,7 +2180,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
* **platform-server:** update minimum domino version to latest released ([#28893](https://github.com/angular/angular/issues/28893)) ([79e2ca0](https://github.com/angular/angular/commit/79e2ca0))
|
* **platform-server:** update minimum domino version to latest released ([#28893](https://github.com/angular/angular/issues/28893)) ([79e2ca0](https://github.com/angular/angular/commit/79e2ca0))
|
||||||
* **router:** removed obsolete TODO comment ([#29085](https://github.com/angular/angular/issues/29085)) ([72ecc45](https://github.com/angular/angular/commit/72ecc45))
|
* **router:** removed obsolete TODO comment ([#29085](https://github.com/angular/angular/issues/29085)) ([72ecc45](https://github.com/angular/angular/commit/72ecc45))
|
||||||
* **service-worker:** detect new version even if files are identical to an old one ([#26006](https://github.com/angular/angular/issues/26006)) ([586234b](https://github.com/angular/angular/commit/586234b)), closes [#24338](https://github.com/angular/angular/issues/24338)
|
* **service-worker:** detect new version even if files are identical to an old one ([#26006](https://github.com/angular/angular/issues/26006)) ([586234b](https://github.com/angular/angular/commit/586234b)), closes [#24338](https://github.com/angular/angular/issues/24338)
|
||||||
* **service-worker:** ignore passive mixed content requests ([#25994](https://github.com/angular/angular/issues/25994)) ([48214e2](https://github.com/angular/angular/commit/48214e2)), closes [/github.com/angular/angular/issues/23012#issuecomment-376430187](https://github.com/angular/angular/issues/23012/issues/issuecomment-376430187) [#23012](https://github.com/angular/angular/issues/23012)
|
* **service-worker:** ignore passive mixed content requests ([#25994](https://github.com/angular/angular/issues/25994)) ([48214e2](https://github.com/angular/angular/commit/48214e2)), closes [23012#issuecomment-376430187](https://github.com/angular/angular/issues/23012#issuecomment-376430187) [#23012](https://github.com/angular/angular/issues/23012)
|
||||||
* **bazel:** Pin browsers for schematics ([#28913](https://github.com/angular/angular/issues/28913)) ([1145bdb](https://github.com/angular/angular/commit/1145bdb))
|
* **bazel:** Pin browsers for schematics ([#28913](https://github.com/angular/angular/issues/28913)) ([1145bdb](https://github.com/angular/angular/commit/1145bdb))
|
||||||
* **bazel:** rxjs_umd_modules should always be present ([#28881](https://github.com/angular/angular/issues/28881)) ([9ae14db](https://github.com/angular/angular/commit/9ae14db))
|
* **bazel:** rxjs_umd_modules should always be present ([#28881](https://github.com/angular/angular/issues/28881)) ([9ae14db](https://github.com/angular/angular/commit/9ae14db))
|
||||||
* **compiler:** use correct variable in invalid function ([#28656](https://github.com/angular/angular/issues/28656)) ([f75acbd](https://github.com/angular/angular/commit/f75acbd))
|
* **compiler:** use correct variable in invalid function ([#28656](https://github.com/angular/angular/issues/28656)) ([f75acbd](https://github.com/angular/angular/commit/f75acbd))
|
||||||
@ -2259,6 +2242,7 @@ To learn about the release highlights and our CLI-powered automated update workf
|
|||||||
|
|
||||||
* **core:** deprecate integration with the Web Tracing Framework (WTF) ([#30642](https://github.com/angular/angular/issues/30642)) ([b408445](https://github.com/angular/angular/commit/b408445))
|
* **core:** deprecate integration with the Web Tracing Framework (WTF) ([#30642](https://github.com/angular/angular/issues/30642)) ([b408445](https://github.com/angular/angular/commit/b408445))
|
||||||
* **platform-webworker:** deprecate platform-webworker ([#30642](https://github.com/angular/angular/issues/30642)) ([361f181](https://github.com/angular/angular/commit/361f181))
|
* **platform-webworker:** deprecate platform-webworker ([#30642](https://github.com/angular/angular/issues/30642)) ([361f181](https://github.com/angular/angular/commit/361f181))
|
||||||
|
* `TestBed.get()` has two signatures, one which is typed and another which accepts and returns `any`. The signature for `any` is deprecated; all usage of `TestBed.get()` should go through the typed API. This mainly affects string tokens
|
||||||
(which aren't supported) and abstract class tokens.
|
(which aren't supported) and abstract class tokens.
|
||||||
|
|
||||||
Before:
|
Before:
|
||||||
@ -2411,7 +2395,7 @@ This release contains various API docs improvements.
|
|||||||
* **animations:** ensure `position` and `display` styles are handled outside of keyframes/web-animations ([#28911](https://github.com/angular/angular/issues/28911)) ([86981b3](https://github.com/angular/angular/commit/86981b3)), closes [#24923](https://github.com/angular/angular/issues/24923) [#25635](https://github.com/angular/angular/issues/25635)
|
* **animations:** ensure `position` and `display` styles are handled outside of keyframes/web-animations ([#28911](https://github.com/angular/angular/issues/28911)) ([86981b3](https://github.com/angular/angular/commit/86981b3)), closes [#24923](https://github.com/angular/angular/issues/24923) [#25635](https://github.com/angular/angular/issues/25635)
|
||||||
* **router:** removed obsolete TODO comment ([#29085](https://github.com/angular/angular/issues/29085)) ([2a25ac2](https://github.com/angular/angular/commit/2a25ac2))
|
* **router:** removed obsolete TODO comment ([#29085](https://github.com/angular/angular/issues/29085)) ([2a25ac2](https://github.com/angular/angular/commit/2a25ac2))
|
||||||
* **service-worker:** detect new version even if files are identical to an old one ([#26006](https://github.com/angular/angular/issues/26006)) ([5669333](https://github.com/angular/angular/commit/5669333)), closes [#24338](https://github.com/angular/angular/issues/24338)
|
* **service-worker:** detect new version even if files are identical to an old one ([#26006](https://github.com/angular/angular/issues/26006)) ([5669333](https://github.com/angular/angular/commit/5669333)), closes [#24338](https://github.com/angular/angular/issues/24338)
|
||||||
* **service-worker:** ignore passive mixed content requests ([#25994](https://github.com/angular/angular/issues/25994)) ([b598e88](https://github.com/angular/angular/commit/b598e88)), closes [/github.com/angular/angular/issues/23012#issuecomment-376430187](https://github.com/angular/angular/issues/23012/issues/issuecomment-376430187) [#23012](https://github.com/angular/angular/issues/23012)
|
* **service-worker:** ignore passive mixed content requests ([#25994](https://github.com/angular/angular/issues/25994)) ([b598e88](https://github.com/angular/angular/commit/b598e88)), closes [23012#issuecomment-376430187](https://github.com/angular/angular/issues/23012#issuecomment-376430187) [#23012](https://github.com/angular/angular/issues/23012)
|
||||||
|
|
||||||
|
|
||||||
<a name="7.2.7"></a>
|
<a name="7.2.7"></a>
|
||||||
@ -2507,6 +2491,14 @@ This release contains various API docs improvements.
|
|||||||
# [8.0.0-beta.0](https://github.com/angular/angular/compare/7.2.0...8.0.0-beta.0) (2019-01-16)
|
# [8.0.0-beta.0](https://github.com/angular/angular/compare/7.2.0...8.0.0-beta.0) (2019-01-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Performance Improvements
|
### Performance Improvements
|
||||||
|
|
||||||
|
|
||||||
@ -2654,9 +2646,42 @@ This release contains various API docs improvements.
|
|||||||
# [7.1.0](https://github.com/angular/angular/compare/7.1.0-rc.0...7.1.0) (2018-11-21)
|
# [7.1.0](https://github.com/angular/angular/compare/7.1.0-rc.0...7.1.0) (2018-11-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **core:** allow null value for renderer setElement(…) ([#17065](https://github.com/angular/angular/issues/17065)) ([ff15043](https://github.com/angular/angular/commit/ff15043)), closes [#13686](https://github.com/angular/angular/issues/13686)
|
||||||
|
* **router:** fix regression where navigateByUrl promise didn't resolve on CanLoad failure ([#26455](https://github.com/angular/angular/issues/26455)) ([1c9b065](https://github.com/angular/angular/commit/1c9b065)), closes [#26284](https://github.com/angular/angular/issues/26284)
|
||||||
|
* **service-worker:** clean up caches from old SW versions ([#26319](https://github.com/angular/angular/issues/26319)) ([2326b9c](https://github.com/angular/angular/commit/2326b9c))
|
||||||
|
* **upgrade:** properly destroy upgraded component elements and descendants ([#26209](https://github.com/angular/angular/issues/26209)) ([071934e](https://github.com/angular/angular/commit/071934e)), closes [#26208](https://github.com/angular/angular/issues/26208)
|
||||||
|
* **compiler:** generate inputs with aliases properly ([#26774](https://github.com/angular/angular/issues/26774)) ([19fcfc3](https://github.com/angular/angular/commit/19fcfc3))
|
||||||
|
* **compiler:** generate relative paths only in summary file errors ([#26759](https://github.com/angular/angular/issues/26759)) ([56f44be](https://github.com/angular/angular/commit/56f44be))
|
||||||
|
* **core:** ignore comment nodes under unsafe elements ([#25879](https://github.com/angular/angular/issues/25879)) ([d5cbcef](https://github.com/angular/angular/commit/d5cbcef))
|
||||||
|
* **core:** Remove static dependency from @angular/core to @angular/compiler ([#26734](https://github.com/angular/angular/issues/26734)) ([d042c4a](https://github.com/angular/angular/commit/d042c4a))
|
||||||
|
* **core:** support computed base class in metadata inheritance ([#24014](https://github.com/angular/angular/issues/24014)) ([95743e3](https://github.com/angular/angular/commit/95743e3))
|
||||||
|
* **bazel:** unknown replay compiler error in windows ([#26711](https://github.com/angular/angular/issues/26711)) ([aed95fd](https://github.com/angular/angular/commit/aed95fd))
|
||||||
|
* **core:** ensure that `ɵdefineNgModule` is available in flat-file formats ([#26403](https://github.com/angular/angular/issues/26403)) ([a64859b](https://github.com/angular/angular/commit/a64859b))
|
||||||
|
* **router:** remove type bludgeoning of context and outlet when running CanDeactivate ([#26496](https://github.com/angular/angular/issues/26496)) ([496372d](https://github.com/angular/angular/commit/496372d)), closes [#18253](https://github.com/angular/angular/issues/18253)
|
||||||
|
* **service-worker:** add typing to public api guard and fix lint errors ([#25860](https://github.com/angular/angular/issues/25860)) ([1061875](https://github.com/angular/angular/commit/1061875))
|
||||||
|
* **upgrade:** improve downgrading-related error messages ([#26217](https://github.com/angular/angular/issues/26217)) ([7dbc103](https://github.com/angular/angular/commit/7dbc103))
|
||||||
|
* **upgrade:** make typings compatible with older AngularJS typings ([#26880](https://github.com/angular/angular/issues/26880)) ([64647af](https://github.com/angular/angular/commit/64647af)), closes [#26420](https://github.com/angular/angular/issues/26420)
|
||||||
|
* **compiler-cli:** add missing tslib dependency ([#27063](https://github.com/angular/angular/issues/27063)) ([c31e78f](https://github.com/angular/angular/commit/c31e78f))
|
||||||
|
* **compiler-cli:** only pass canonical genfile paths to compiler host ([#27062](https://github.com/angular/angular/issues/27062)) ([0ada23a](https://github.com/angular/angular/commit/0ada23a))
|
||||||
|
* **router:** add `relativeLinkResolution` to `recognize` operator ([#26990](https://github.com/angular/angular/issues/26990)) ([a752971](https://github.com/angular/angular/commit/a752971)), closes [#26983](https://github.com/angular/angular/issues/26983)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* **bazel:** Bazel workspace schematics ([#26971](https://github.com/angular/angular/issues/26971)) ([b07bd30](https://github.com/angular/angular/commit/b07bd30))
|
* **bazel:** Bazel workspace schematics ([#26971](https://github.com/angular/angular/issues/26971)) ([b07bd30](https://github.com/angular/angular/commit/b07bd30))
|
||||||
|
* **router:** add prioritizedGuardValue operator optimization and allowing UrlTree return from guard ([#26478](https://github.com/angular/angular/issues/26478)) ([fdfedce](https://github.com/angular/angular/commit/fdfedce))
|
||||||
|
* **compiler:** ability to mark an InvokeFunctionExpr as pure ([#26860](https://github.com/angular/angular/issues/26860)) ([4dfa71f](https://github.com/angular/angular/commit/4dfa71f))
|
||||||
|
* **forms:** add updateOn option to FormBuilder ([#24599](https://github.com/angular/angular/issues/24599)) ([e9e804f](https://github.com/angular/angular/commit/e9e804f))
|
||||||
|
* **router:** allow guards to return UrlTree as well as boolean ([#26521](https://github.com/angular/angular/issues/26521)) ([081f95c](https://github.com/angular/angular/commit/081f95c))
|
||||||
|
* **router:** allow redirect from guards by returning UrlTree ([#26521](https://github.com/angular/angular/issues/26521)) ([152ca66](https://github.com/angular/angular/commit/152ca66))
|
||||||
|
* **router:** guard returning UrlTree cancels current navigation and redirects ([#26521](https://github.com/angular/angular/issues/26521)) ([4e9f2e5](https://github.com/angular/angular/commit/4e9f2e5)), closes [#24618](https://github.com/angular/angular/issues/24618)
|
||||||
|
* **service-worker:** add typing for messagesClicked in SwPush service ([#25860](https://github.com/angular/angular/issues/25860)) ([c78c221](https://github.com/angular/angular/commit/c78c221))
|
||||||
|
* **service-worker:** close notifications and focus window on click ([#25860](https://github.com/angular/angular/issues/25860)) ([f5d5a3d](https://github.com/angular/angular/commit/f5d5a3d))
|
||||||
|
* **service-worker:** handle 'notificationclick' events ([#25860](https://github.com/angular/angular/issues/25860)) ([cf6ea28](https://github.com/angular/angular/commit/cf6ea28)), closes [#20956](https://github.com/angular/angular/issues/20956) [#22311](https://github.com/angular/angular/issues/22311)
|
||||||
|
* **upgrade:** support downgrading multiple modules ([#26217](https://github.com/angular/angular/issues/26217)) ([93837e9](https://github.com/angular/angular/commit/93837e9)), closes [#26062](https://github.com/angular/angular/issues/26062)
|
||||||
|
* **router:** add pathParamsChange mode for runGuardsAndResolvers ([#26861](https://github.com/angular/angular/issues/26861)) ([bf6ac6c](https://github.com/angular/angular/commit/bf6ac6c)), closes [#18253](https://github.com/angular/angular/issues/18253)
|
||||||
|
|
||||||
|
|
||||||
<a name="7.1.0-rc.0"></a>
|
<a name="7.1.0-rc.0"></a>
|
||||||
@ -2759,7 +2784,10 @@ This release contains various API docs improvements.
|
|||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
* **core:** allow null value for renderer setElement(…) ([#17065](https://github.com/angular/angular/issues/17065)) ([ff15043](https://github.com/angular/angular/commit/ff15043)), closes [#13686](https://github.com/angular/angular/issues/13686)
|
||||||
|
* **router:** fix regression where navigateByUrl promise didn't resolve on CanLoad failure ([#26455](https://github.com/angular/angular/issues/26455)) ([1c9b065](https://github.com/angular/angular/commit/1c9b065)), closes [#26284](https://github.com/angular/angular/issues/26284)
|
||||||
* **service-worker:** clean up caches from old SW versions ([#26319](https://github.com/angular/angular/issues/26319)) ([2326b9c](https://github.com/angular/angular/commit/2326b9c))
|
* **service-worker:** clean up caches from old SW versions ([#26319](https://github.com/angular/angular/issues/26319)) ([2326b9c](https://github.com/angular/angular/commit/2326b9c))
|
||||||
|
* **upgrade:** properly destroy upgraded component elements and descendants ([#26209](https://github.com/angular/angular/issues/26209)) ([071934e](https://github.com/angular/angular/commit/071934e)), closes [#26208](https://github.com/angular/angular/issues/26208)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
@ -2931,6 +2959,7 @@ Note: the 6.1.5 release on npm accidentally glitched-out midway, so we cut 6.1.6
|
|||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
* **animations:** always render end-state styles for orphaned DOM nodes ([#24236](https://github.com/angular/angular/issues/24236)) ([dc4a3d0](https://github.com/angular/angular/commit/dc4a3d0))
|
* **animations:** always render end-state styles for orphaned DOM nodes ([#24236](https://github.com/angular/angular/issues/24236)) ([dc4a3d0](https://github.com/angular/angular/commit/dc4a3d0))
|
||||||
|
* **animations:** set animations styles properly on platform-server ([#24624](https://github.com/angular/angular/issues/24624)) ([0b356d4](https://github.com/angular/angular/commit/0b356d4))
|
||||||
* **animations:** do not throw errors when a destroyed component is animated ([#23836](https://github.com/angular/angular/issues/23836)) ([d2a8687](https://github.com/angular/angular/commit/d2a8687))
|
* **animations:** do not throw errors when a destroyed component is animated ([#23836](https://github.com/angular/angular/issues/23836)) ([d2a8687](https://github.com/angular/angular/commit/d2a8687))
|
||||||
* **animations:** Fix browser detection logic ([#24188](https://github.com/angular/angular/issues/24188)) ([b492b9e](https://github.com/angular/angular/commit/b492b9e))
|
* **animations:** Fix browser detection logic ([#24188](https://github.com/angular/angular/issues/24188)) ([b492b9e](https://github.com/angular/angular/commit/b492b9e))
|
||||||
* **animations:** properly clean up queried element styles in safari/edge ([#23633](https://github.com/angular/angular/issues/23633)) ([da9ff25](https://github.com/angular/angular/commit/da9ff25))
|
* **animations:** properly clean up queried element styles in safari/edge ([#23633](https://github.com/angular/angular/issues/23633)) ([da9ff25](https://github.com/angular/angular/commit/da9ff25))
|
||||||
@ -2942,6 +2971,7 @@ Note: the 6.1.5 release on npm accidentally glitched-out midway, so we cut 6.1.6
|
|||||||
* **common:** format fractional seconds ([#24844](https://github.com/angular/angular/issues/24844)) ([0b4d85e](https://github.com/angular/angular/commit/0b4d85e)), closes [#24831](https://github.com/angular/angular/issues/24831)
|
* **common:** format fractional seconds ([#24844](https://github.com/angular/angular/issues/24844)) ([0b4d85e](https://github.com/angular/angular/commit/0b4d85e)), closes [#24831](https://github.com/angular/angular/issues/24831)
|
||||||
* **common:** properly update collection reference in NgForOf ([#24684](https://github.com/angular/angular/issues/24684)) ([ff84c5c](https://github.com/angular/angular/commit/ff84c5c)), closes [#24155](https://github.com/angular/angular/issues/24155)
|
* **common:** properly update collection reference in NgForOf ([#24684](https://github.com/angular/angular/issues/24684)) ([ff84c5c](https://github.com/angular/angular/commit/ff84c5c)), closes [#24155](https://github.com/angular/angular/issues/24155)
|
||||||
* **common:** use correct currency format for locale de-AT ([#24658](https://github.com/angular/angular/issues/24658)) ([dcabb05](https://github.com/angular/angular/commit/dcabb05)), closes [#24609](https://github.com/angular/angular/issues/24609)
|
* **common:** use correct currency format for locale de-AT ([#24658](https://github.com/angular/angular/issues/24658)) ([dcabb05](https://github.com/angular/angular/commit/dcabb05)), closes [#24609](https://github.com/angular/angular/issues/24609)
|
||||||
|
* **common:** use correct ICU plural for locale mk ([#24659](https://github.com/angular/angular/issues/24659)) ([64a8584](https://github.com/angular/angular/commit/64a8584))
|
||||||
* **compiler:** fix a few non-tree-shakeable code patterns ([#24677](https://github.com/angular/angular/issues/24677)) ([50d4a4f](https://github.com/angular/angular/commit/50d4a4f))
|
* **compiler:** fix a few non-tree-shakeable code patterns ([#24677](https://github.com/angular/angular/issues/24677)) ([50d4a4f](https://github.com/angular/angular/commit/50d4a4f))
|
||||||
* **compiler:** i18n_extractor now outputs the correct source file name ([#24885](https://github.com/angular/angular/issues/24885)) ([c8ad965](https://github.com/angular/angular/commit/c8ad965)), closes [#24884](https://github.com/angular/angular/issues/24884)
|
* **compiler:** i18n_extractor now outputs the correct source file name ([#24885](https://github.com/angular/angular/issues/24885)) ([c8ad965](https://github.com/angular/angular/commit/c8ad965)), closes [#24884](https://github.com/angular/angular/issues/24884)
|
||||||
* **compiler:** support `.` in import statements. ([#20634](https://github.com/angular/angular/issues/20634)) ([d8f7b29](https://github.com/angular/angular/commit/d8f7b29)), closes [#20363](https://github.com/angular/angular/issues/20363)
|
* **compiler:** support `.` in import statements. ([#20634](https://github.com/angular/angular/issues/20634)) ([d8f7b29](https://github.com/angular/angular/commit/d8f7b29)), closes [#20363](https://github.com/angular/angular/issues/20363)
|
||||||
@ -2977,6 +3007,7 @@ Note: the 6.1.5 release on npm accidentally glitched-out midway, so we cut 6.1.6
|
|||||||
* **service-worker:** don't include sourceMappingURL in ngsw-worker ([#24877](https://github.com/angular/angular/issues/24877)) ([8620373](https://github.com/angular/angular/commit/8620373)), closes [#23596](https://github.com/angular/angular/issues/23596)
|
* **service-worker:** don't include sourceMappingURL in ngsw-worker ([#24877](https://github.com/angular/angular/issues/24877)) ([8620373](https://github.com/angular/angular/commit/8620373)), closes [#23596](https://github.com/angular/angular/issues/23596)
|
||||||
* **service-worker:** avoid network requests when looking up hashed resources in cache ([#24127](https://github.com/angular/angular/issues/24127)) ([52d43a9](https://github.com/angular/angular/commit/52d43a9))
|
* **service-worker:** avoid network requests when looking up hashed resources in cache ([#24127](https://github.com/angular/angular/issues/24127)) ([52d43a9](https://github.com/angular/angular/commit/52d43a9))
|
||||||
* **service-worker:** fix `SwPush.unsubscribe()` ([#24162](https://github.com/angular/angular/issues/24162)) ([3ed2d75](https://github.com/angular/angular/commit/3ed2d75)), closes [#24095](https://github.com/angular/angular/issues/24095)
|
* **service-worker:** fix `SwPush.unsubscribe()` ([#24162](https://github.com/angular/angular/issues/24162)) ([3ed2d75](https://github.com/angular/angular/commit/3ed2d75)), closes [#24095](https://github.com/angular/angular/issues/24095)
|
||||||
|
* **service-worker:** add badge to NOTIFICATION_OPTION_NAMES ([#23241](https://github.com/angular/angular/issues/23241)) ([fb59b2d](https://github.com/angular/angular/commit/fb59b2d)), closes [#23196](https://github.com/angular/angular/issues/23196)
|
||||||
* **service-worker:** check platformBrowser before accessing navigator.serviceWorker ([#21231](https://github.com/angular/angular/issues/21231)) ([0bdd30e](https://github.com/angular/angular/commit/0bdd30e))
|
* **service-worker:** check platformBrowser before accessing navigator.serviceWorker ([#21231](https://github.com/angular/angular/issues/21231)) ([0bdd30e](https://github.com/angular/angular/commit/0bdd30e))
|
||||||
* **service-worker:** correctly handle requests with empty `clientId` ([#23625](https://github.com/angular/angular/issues/23625)) ([e0ed59e](https://github.com/angular/angular/commit/e0ed59e)), closes [#23526](https://github.com/angular/angular/issues/23526)
|
* **service-worker:** correctly handle requests with empty `clientId` ([#23625](https://github.com/angular/angular/issues/23625)) ([e0ed59e](https://github.com/angular/angular/commit/e0ed59e)), closes [#23526](https://github.com/angular/angular/issues/23526)
|
||||||
* **service-worker:** deprecate `versionedFiles` in asset-group resources ([#23584](https://github.com/angular/angular/issues/23584)) ([1d378e2](https://github.com/angular/angular/commit/1d378e2))
|
* **service-worker:** deprecate `versionedFiles` in asset-group resources ([#23584](https://github.com/angular/angular/issues/23584)) ([1d378e2](https://github.com/angular/angular/commit/1d378e2))
|
||||||
@ -3177,6 +3208,8 @@ To learn about the release highlights and our new CLI-powered update workflow fo
|
|||||||
* **forms:** multiple validators for array method ([#20766](https://github.com/angular/angular/issues/20766)) ([941e88f](https://github.com/angular/angular/commit/941e88f)), closes [#20665](https://github.com/angular/angular/issues/20665)
|
* **forms:** multiple validators for array method ([#20766](https://github.com/angular/angular/issues/20766)) ([941e88f](https://github.com/angular/angular/commit/941e88f)), closes [#20665](https://github.com/angular/angular/issues/20665)
|
||||||
* **forms:** allow markAsPending to emit events ([#20212](https://github.com/angular/angular/issues/20212)) ([e86b64b](https://github.com/angular/angular/commit/e86b64b)), closes [#17958](https://github.com/angular/angular/issues/17958)
|
* **forms:** allow markAsPending to emit events ([#20212](https://github.com/angular/angular/issues/20212)) ([e86b64b](https://github.com/angular/angular/commit/e86b64b)), closes [#17958](https://github.com/angular/angular/issues/17958)
|
||||||
* **platform-browser:** add token marking which the type of animation module nearest in the injector tree ([#23075](https://github.com/angular/angular/issues/23075)) ([b551f84](https://github.com/angular/angular/commit/b551f84))
|
* **platform-browser:** add token marking which the type of animation module nearest in the injector tree ([#23075](https://github.com/angular/angular/issues/23075)) ([b551f84](https://github.com/angular/angular/commit/b551f84))
|
||||||
|
* **platform-browser:** do not throw error when Hammer.js not loaded ([#22257](https://github.com/angular/angular/issues/22257)) ([991300b](https://github.com/angular/angular/commit/991300b)), closes [#16992](https://github.com/angular/angular/issues/16992)
|
||||||
|
* **platform-browser:** fix [#19604](https://github.com/angular/angular/issues/19604), can config hammerOptions ([#21979](https://github.com/angular/angular/issues/21979)) ([1d571b2](https://github.com/angular/angular/commit/1d571b2))
|
||||||
* **platform-server:** bump Domino to v2.0 ([#22411](https://github.com/angular/angular/issues/22411)) ([d3827a0](https://github.com/angular/angular/commit/d3827a0))
|
* **platform-server:** bump Domino to v2.0 ([#22411](https://github.com/angular/angular/issues/22411)) ([d3827a0](https://github.com/angular/angular/commit/d3827a0))
|
||||||
* **router:** add navigationSource and restoredState to NavigationStart event ([#21728](https://github.com/angular/angular/issues/21728)) ([c40ae7f](https://github.com/angular/angular/commit/c40ae7f))
|
* **router:** add navigationSource and restoredState to NavigationStart event ([#21728](https://github.com/angular/angular/issues/21728)) ([c40ae7f](https://github.com/angular/angular/commit/c40ae7f))
|
||||||
* **service-worker:** add support for configuring navigations URLs ([#23339](https://github.com/angular/angular/issues/23339)) ([08325aa](https://github.com/angular/angular/commit/08325aa)), closes [#20404](https://github.com/angular/angular/issues/20404)
|
* **service-worker:** add support for configuring navigations URLs ([#23339](https://github.com/angular/angular/issues/23339)) ([08325aa](https://github.com/angular/angular/commit/08325aa)), closes [#20404](https://github.com/angular/angular/issues/20404)
|
||||||
@ -3395,7 +3428,12 @@ To learn about the release highlights and our new CLI-powered update workflow fo
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **platform-server:** generate correct stylings for camel case names ([#22263](https://github.com/angular/angular/issues/22263)) ([de02a7a](https://github.com/angular/angular/commit/de02a7a)), closes [#19235](https://github.com/angular/angular/issues/19235)
|
||||||
|
* **router:** don't mutate route configs ([#22358](https://github.com/angular/angular/issues/22358)) ([8f0a064](https://github.com/angular/angular/commit/8f0a064)), closes [#22203](https://github.com/angular/angular/issues/22203)
|
||||||
* **router:** fix URL serialization so special characters are only encoded where needed ([#22337](https://github.com/angular/angular/issues/22337)) ([789a47e](https://github.com/angular/angular/commit/789a47e)), closes [#10280](https://github.com/angular/angular/issues/10280)
|
* **router:** fix URL serialization so special characters are only encoded where needed ([#22337](https://github.com/angular/angular/issues/22337)) ([789a47e](https://github.com/angular/angular/commit/789a47e)), closes [#10280](https://github.com/angular/angular/issues/10280)
|
||||||
|
* **upgrade:** correctly destroy nested downgraded component ([#22400](https://github.com/angular/angular/issues/22400)) ([4aef9de](https://github.com/angular/angular/commit/4aef9de)), closes [#22392](https://github.com/angular/angular/issues/22392)
|
||||||
|
* **upgrade:** correctly handle `=` bindings in `@angular/upgrade` ([#22167](https://github.com/angular/angular/issues/22167)) ([6638390](https://github.com/angular/angular/commit/6638390))
|
||||||
|
* **upgrade:** fix empty transclusion content with AngularJS@>=1.5.8 ([#22167](https://github.com/angular/angular/issues/22167)) ([a9a0e27](https://github.com/angular/angular/commit/a9a0e27)), closes [#22175](https://github.com/angular/angular/issues/22175)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -3790,6 +3828,15 @@ Note: Due to an animation fix back in 5.1.1 ([c2b3792](https://github.com/angula
|
|||||||
<a name="5.1.0-beta.0"></a>
|
<a name="5.1.0-beta.0"></a>
|
||||||
# [5.1.0-beta.0](https://github.com/angular/angular/compare/5.0.0-rc.4...5.1.0-beta.0) (2017-11-08)
|
# [5.1.0-beta.0](https://github.com/angular/angular/compare/5.0.0-rc.4...5.1.0-beta.0) (2017-11-08)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **compiler:** don't overwrite missingTranslation's value in JIT ([#19952](https://github.com/angular/angular/issues/19952)) ([799cbb9](https://github.com/angular/angular/commit/799cbb9))
|
||||||
|
* **compiler:** report a reasonable error with invalid metadata ([#20062](https://github.com/angular/angular/issues/20062)) ([da22c48](https://github.com/angular/angular/commit/da22c48))
|
||||||
|
* **compiler-cli:** don't report emit diagnostics when `--noEmitOnError` is off ([#20063](https://github.com/angular/angular/issues/20063)) ([8639995](https://github.com/angular/angular/commit/8639995))
|
||||||
|
* **core:** `__symbol__` should return `__zone_symbol__` without zone.js loaded ([#19541](https://github.com/angular/angular/issues/19541)) ([678d1cf](https://github.com/angular/angular/commit/678d1cf))
|
||||||
|
* **core:** should support event.stopImmediatePropagation ([#19222](https://github.com/angular/angular/issues/19222)) ([7083791](https://github.com/angular/angular/commit/7083791))
|
||||||
|
* **platform-browser:** support Symbols in custom `jasmineToString()` method ([#19794](https://github.com/angular/angular/issues/19794)) ([5a6efa7](https://github.com/angular/angular/commit/5a6efa7))
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
* **compiler:** introduce `TestBed.overrideTemplateUsingTestingModule` ([a460066](https://github.com/angular/angular/commit/a460066)), closes [#19815](https://github.com/angular/angular/issues/19815)
|
* **compiler:** introduce `TestBed.overrideTemplateUsingTestingModule` ([a460066](https://github.com/angular/angular/commit/a460066)), closes [#19815](https://github.com/angular/angular/issues/19815)
|
||||||
@ -3825,12 +3872,14 @@ Note: Due to an animation fix back in 5.1.1 ([c2b3792](https://github.com/angula
|
|||||||
* **compiler-cli:** add watch mode to `ngc` ([#18818](https://github.com/angular/angular/issues/18818)) ([06d01b2](https://github.com/angular/angular/commit/06d01b2))
|
* **compiler-cli:** add watch mode to `ngc` ([#18818](https://github.com/angular/angular/issues/18818)) ([06d01b2](https://github.com/angular/angular/commit/06d01b2))
|
||||||
* **compiler-cli:** lower metadata `useValue` and `data` literal fields ([#18905](https://github.com/angular/angular/issues/18905)) ([0e64261](https://github.com/angular/angular/commit/0e64261))
|
* **compiler-cli:** lower metadata `useValue` and `data` literal fields ([#18905](https://github.com/angular/angular/issues/18905)) ([0e64261](https://github.com/angular/angular/commit/0e64261))
|
||||||
* **compiler:** add representation of placeholders to xliff & xmb ([b3085e9](https://github.com/angular/angular/commit/b3085e9)), closes [#17345](https://github.com/angular/angular/issues/17345)
|
* **compiler:** add representation of placeholders to xliff & xmb ([b3085e9](https://github.com/angular/angular/commit/b3085e9)), closes [#17345](https://github.com/angular/angular/issues/17345)
|
||||||
|
* **compiler:** allow multiple exportAs names ([#18723](https://github.com/angular/angular/issues/18723)) ([7ec28fe](https://github.com/angular/angular/commit/7ec28fe))
|
||||||
* **compiler:** enabled strict checking of parameters to an `@Injectable` ([#19412](https://github.com/angular/angular/issues/19412)) ([dfb8d21](https://github.com/angular/angular/commit/dfb8d21))
|
* **compiler:** enabled strict checking of parameters to an `@Injectable` ([#19412](https://github.com/angular/angular/issues/19412)) ([dfb8d21](https://github.com/angular/angular/commit/dfb8d21))
|
||||||
* **compiler:** make `.ngsummary.json` files portable ([2572bf5](https://github.com/angular/angular/commit/2572bf5))
|
* **compiler:** make `.ngsummary.json` files portable ([2572bf5](https://github.com/angular/angular/commit/2572bf5))
|
||||||
* **compiler:** reuse the TypeScript typecheck for template typechecking. ([#19152](https://github.com/angular/angular/issues/19152)) ([996c7c2](https://github.com/angular/angular/commit/996c7c2))
|
* **compiler:** reuse the TypeScript typecheck for template typechecking. ([#19152](https://github.com/angular/angular/issues/19152)) ([996c7c2](https://github.com/angular/angular/commit/996c7c2))
|
||||||
* **compiler:** set `enableLegacyTemplate` to false by default ([#18756](https://github.com/angular/angular/issues/18756)) ([56238fe](https://github.com/angular/angular/commit/56238fe))
|
* **compiler:** set `enableLegacyTemplate` to false by default ([#18756](https://github.com/angular/angular/issues/18756)) ([56238fe](https://github.com/angular/angular/commit/56238fe))
|
||||||
* **compiler:** use typescript for resolving resource paths ([43226cb](https://github.com/angular/angular/commit/43226cb))
|
* **compiler:** use typescript for resolving resource paths ([43226cb](https://github.com/angular/angular/commit/43226cb))
|
||||||
* **core:** Create StaticInjector which does not depend on Reflect polyfill. ([d9d00bd](https://github.com/angular/angular/commit/d9d00bd))
|
* **core:** Create StaticInjector which does not depend on Reflect polyfill. ([d9d00bd](https://github.com/angular/angular/commit/d9d00bd))
|
||||||
|
* **core:** add option to remove blank text nodes from compiled templates ([#18823](https://github.com/angular/angular/issues/18823)) ([b8b551c](https://github.com/angular/angular/commit/b8b551c))
|
||||||
* **core:** support for bootstrap with custom zone ([#17672](https://github.com/angular/angular/issues/17672)) ([344a5ca](https://github.com/angular/angular/commit/344a5ca))
|
* **core:** support for bootstrap with custom zone ([#17672](https://github.com/angular/angular/issues/17672)) ([344a5ca](https://github.com/angular/angular/commit/344a5ca))
|
||||||
* **forms:** add default updateOn values for groups and arrays ([#18536](https://github.com/angular/angular/issues/18536)) ([ff5c58b](https://github.com/angular/angular/commit/ff5c58b))
|
* **forms:** add default updateOn values for groups and arrays ([#18536](https://github.com/angular/angular/issues/18536)) ([ff5c58b](https://github.com/angular/angular/commit/ff5c58b))
|
||||||
* **forms:** add options arg to abstract controls ([ebef5e6](https://github.com/angular/angular/commit/ebef5e6))
|
* **forms:** add options arg to abstract controls ([ebef5e6](https://github.com/angular/angular/commit/ebef5e6))
|
||||||
@ -4189,6 +4238,7 @@ Note: the 4.4.0 release on npm accidentally glitched-out midway, so we cut 4.4.1
|
|||||||
* **animations:** properly collect :enter nodes that exist within multi-level DOM trees ([40f77cb](https://github.com/angular/angular/commit/40f77cb)), closes [#17632](https://github.com/angular/angular/issues/17632)
|
* **animations:** properly collect :enter nodes that exist within multi-level DOM trees ([40f77cb](https://github.com/angular/angular/commit/40f77cb)), closes [#17632](https://github.com/angular/angular/issues/17632)
|
||||||
* **animations:** compute removal node height correctly ([185075d](https://github.com/angular/angular/commit/185075d))
|
* **animations:** compute removal node height correctly ([185075d](https://github.com/angular/angular/commit/185075d))
|
||||||
* **animations:** do not treat a `0` animation state as `void` ([451257a](https://github.com/angular/angular/commit/451257a))
|
* **animations:** do not treat a `0` animation state as `void` ([451257a](https://github.com/angular/angular/commit/451257a))
|
||||||
|
* **animations:** properly collect :enter nodes in a partially updated collection ([6ca4692](https://github.com/angular/angular/commit/6ca4692)), closes [#17440](https://github.com/angular/angular/issues/17440)
|
||||||
* **animations:** remove duplicate license header ([e096a85](https://github.com/angular/angular/commit/e096a85))
|
* **animations:** remove duplicate license header ([e096a85](https://github.com/angular/angular/commit/e096a85))
|
||||||
* **common/http:** document HttpClient, fixing a few other issues ([1855989](https://github.com/angular/angular/commit/1855989))
|
* **common/http:** document HttpClient, fixing a few other issues ([1855989](https://github.com/angular/angular/commit/1855989))
|
||||||
* **common/http:** don't guess Content-Type for FormData bodies ([#18104](https://github.com/angular/angular/issues/18104)) ([4f1e4ff](https://github.com/angular/angular/commit/4f1e4ff)), closes [#18096](https://github.com/angular/angular/issues/18096)
|
* **common/http:** don't guess Content-Type for FormData bodies ([#18104](https://github.com/angular/angular/issues/18104)) ([4f1e4ff](https://github.com/angular/angular/commit/4f1e4ff)), closes [#18096](https://github.com/angular/angular/issues/18096)
|
||||||
@ -4297,6 +4347,7 @@ Note: the 4.4.0 release on npm accidentally glitched-out midway, so we cut 4.4.1
|
|||||||
|
|
||||||
* **animations:** compute removal node height correctly ([185075d](https://github.com/angular/angular/commit/185075d))
|
* **animations:** compute removal node height correctly ([185075d](https://github.com/angular/angular/commit/185075d))
|
||||||
* **animations:** do not treat a `0` animation state as `void` ([451257a](https://github.com/angular/angular/commit/451257a))
|
* **animations:** do not treat a `0` animation state as `void` ([451257a](https://github.com/angular/angular/commit/451257a))
|
||||||
|
* **animations:** properly collect :enter nodes in a partially updated collection ([6ca4692](https://github.com/angular/angular/commit/6ca4692)), closes [#17440](https://github.com/angular/angular/issues/17440)
|
||||||
* **animations:** remove duplicate license header ([b192dd5](https://github.com/angular/angular/commit/b192dd5))
|
* **animations:** remove duplicate license header ([b192dd5](https://github.com/angular/angular/commit/b192dd5))
|
||||||
* **forms:** temp roll back breaking change with min/max directives ([b8c39cd](https://github.com/angular/angular/commit/b8c39cd)), closes [#17491](https://github.com/angular/angular/issues/17491)
|
* **forms:** temp roll back breaking change with min/max directives ([b8c39cd](https://github.com/angular/angular/commit/b8c39cd)), closes [#17491](https://github.com/angular/angular/issues/17491)
|
||||||
|
|
||||||
@ -4532,6 +4583,7 @@ Note: the 4.4.0 release on npm accidentally glitched-out midway, so we cut 4.4.1
|
|||||||
* **benchpress:** Update types for TypeScript nullability support ([14669f2](https://github.com/angular/angular/commit/14669f2))
|
* **benchpress:** Update types for TypeScript nullability support ([14669f2](https://github.com/angular/angular/commit/14669f2))
|
||||||
* **common:** Update types for TypeScript nullability support ([d8b73e4](https://github.com/angular/angular/commit/d8b73e4))
|
* **common:** Update types for TypeScript nullability support ([d8b73e4](https://github.com/angular/angular/commit/d8b73e4))
|
||||||
* **compiler:** fix build error in xliff2 ([bd704c9](https://github.com/angular/angular/commit/bd704c9))
|
* **compiler:** fix build error in xliff2 ([bd704c9](https://github.com/angular/angular/commit/bd704c9))
|
||||||
|
* **compiler:** fix inheritance for AOT with summaries ([#15583](https://github.com/angular/angular/issues/15583)) ([8ef621a](https://github.com/angular/angular/commit/8ef621a))
|
||||||
* **compiler:** ignore calls to unresolved symbols in metadata ([38a7e0d](https://github.com/angular/angular/commit/38a7e0d)), closes [#15969](https://github.com/angular/angular/issues/15969)
|
* **compiler:** ignore calls to unresolved symbols in metadata ([38a7e0d](https://github.com/angular/angular/commit/38a7e0d)), closes [#15969](https://github.com/angular/angular/issues/15969)
|
||||||
* **compiler:** ignore calls to unresolved symbols in metadata ([#15970](https://github.com/angular/angular/issues/15970)) ([ce47d33](https://github.com/angular/angular/commit/ce47d33)), closes [#15969](https://github.com/angular/angular/issues/15969)
|
* **compiler:** ignore calls to unresolved symbols in metadata ([#15970](https://github.com/angular/angular/issues/15970)) ([ce47d33](https://github.com/angular/angular/commit/ce47d33)), closes [#15969](https://github.com/angular/angular/issues/15969)
|
||||||
* **compiler:** Inform user where Quoted error was thrown ([a77b126](https://github.com/angular/angular/commit/a77b126))
|
* **compiler:** Inform user where Quoted error was thrown ([a77b126](https://github.com/angular/angular/commit/a77b126))
|
||||||
@ -4548,8 +4600,10 @@ Note: the 4.4.0 release on npm accidentally glitched-out midway, so we cut 4.4.1
|
|||||||
* **http:** Update types for TypeScript nullability support ([c36ec9b](https://github.com/angular/angular/commit/c36ec9b))
|
* **http:** Update types for TypeScript nullability support ([c36ec9b](https://github.com/angular/angular/commit/c36ec9b))
|
||||||
* **http:** Update types for TypeScript nullability support ([ec028b8](https://github.com/angular/angular/commit/ec028b8))
|
* **http:** Update types for TypeScript nullability support ([ec028b8](https://github.com/angular/angular/commit/ec028b8))
|
||||||
* **language-service:** avoid throwing exceptions when reporting metadata errors ([7764c5c](https://github.com/angular/angular/commit/7764c5c))
|
* **language-service:** avoid throwing exceptions when reporting metadata errors ([7764c5c](https://github.com/angular/angular/commit/7764c5c))
|
||||||
|
* **language-service:** detect when there isn't a tsconfig.json ([258d539](https://github.com/angular/angular/commit/258d539)), closes [#15874](https://github.com/angular/angular/issues/15874)
|
||||||
* **language-service:** improve resilience to incomplete information ([71a8627](https://github.com/angular/angular/commit/71a8627))
|
* **language-service:** improve resilience to incomplete information ([71a8627](https://github.com/angular/angular/commit/71a8627))
|
||||||
* **language-service:** infer correct type of `?.` expressions ([0a3a9af](https://github.com/angular/angular/commit/0a3a9af)), closes [#15885](https://github.com/angular/angular/issues/15885)
|
* **language-service:** infer correct type of `?.` expressions ([0a3a9af](https://github.com/angular/angular/commit/0a3a9af)), closes [#15885](https://github.com/angular/angular/issues/15885)
|
||||||
|
* **language-service:** initialize static reflector correctly ([fe0d02f](https://github.com/angular/angular/commit/fe0d02f)), closes [#15768](https://github.com/angular/angular/issues/15768)
|
||||||
* **language-service:** look for type constructors on canonical symbol ([2ddf3bc](https://github.com/angular/angular/commit/2ddf3bc))
|
* **language-service:** look for type constructors on canonical symbol ([2ddf3bc](https://github.com/angular/angular/commit/2ddf3bc))
|
||||||
* **language-service:** only use canonical symbols ([5a88d2f](https://github.com/angular/angular/commit/5a88d2f))
|
* **language-service:** only use canonical symbols ([5a88d2f](https://github.com/angular/angular/commit/5a88d2f))
|
||||||
* **language-service:** parse extended i18n forms ([bde9771](https://github.com/angular/angular/commit/bde9771))
|
* **language-service:** parse extended i18n forms ([bde9771](https://github.com/angular/angular/commit/bde9771))
|
||||||
@ -4574,6 +4628,7 @@ Note: the 4.4.0 release on npm accidentally glitched-out midway, so we cut 4.4.1
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
* **animations:** Update types for TypeScript nullability support ([38d75d4](https://github.com/angular/angular/commit/38d75d4)), closes [#15870](https://github.com/angular/angular/issues/15870)
|
||||||
* **compiler:** add source files to xmb/xliff translations ([#14705](https://github.com/angular/angular/issues/14705)) ([4054055](https://github.com/angular/angular/commit/4054055)), closes [#14190](https://github.com/angular/angular/issues/14190)
|
* **compiler:** add source files to xmb/xliff translations ([#14705](https://github.com/angular/angular/issues/14705)) ([4054055](https://github.com/angular/angular/commit/4054055)), closes [#14190](https://github.com/angular/angular/issues/14190)
|
||||||
* **compiler:** Implement i18n XLIFF 2.0 serializer ([#14185](https://github.com/angular/angular/issues/14185)) ([09c4cb2](https://github.com/angular/angular/commit/09c4cb2)), closes [#11735](https://github.com/angular/angular/issues/11735)
|
* **compiler:** Implement i18n XLIFF 2.0 serializer ([#14185](https://github.com/angular/angular/issues/14185)) ([09c4cb2](https://github.com/angular/angular/commit/09c4cb2)), closes [#11735](https://github.com/angular/angular/issues/11735)
|
||||||
* **upgrade:** allow setting the angularjs lib at runtime ([#15168](https://github.com/angular/angular/issues/15168)) ([e927aea](https://github.com/angular/angular/commit/e927aea))
|
* **upgrade:** allow setting the angularjs lib at runtime ([#15168](https://github.com/angular/angular/issues/15168)) ([e927aea](https://github.com/angular/angular/commit/e927aea))
|
||||||
@ -5311,18 +5366,27 @@ returned value being an array.
|
|||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **animations:** fix internal jscompiler issue and AOT quoting ([#13798](https://github.com/angular/angular/issues/13798)) ([c2aa981](https://github.com/angular/angular/commit/c2aa981))
|
||||||
|
* **common:** support numeric value as discrete cases for NgPlural ([#13876](https://github.com/angular/angular/issues/13876)) ([f364557](https://github.com/angular/angular/commit/f364557))
|
||||||
* **compiler:** [i18n] XMB/XTB placeholder names can contain only A-Z, 0-9, _n ([d02eab4](https://github.com/angular/angular/commit/d02eab4))
|
* **compiler:** [i18n] XMB/XTB placeholder names can contain only A-Z, 0-9, _n ([d02eab4](https://github.com/angular/angular/commit/d02eab4))
|
||||||
* **compiler:** fix regexp to support firefox 31 ([#14082](https://github.com/angular/angular/issues/14082)) ([b2f9d56](https://github.com/angular/angular/commit/b2f9d56)), closes [#14029](https://github.com/angular/angular/issues/14029) [#13900](https://github.com/angular/angular/issues/13900)
|
* **compiler:** fix regexp to support firefox 31 ([#14082](https://github.com/angular/angular/issues/14082)) ([b2f9d56](https://github.com/angular/angular/commit/b2f9d56)), closes [#14029](https://github.com/angular/angular/issues/14029) [#13900](https://github.com/angular/angular/issues/13900)
|
||||||
* **core:** export animation classes required for Renderer impl ([#14002](https://github.com/angular/angular/issues/14002)) ([83361d8](https://github.com/angular/angular/commit/83361d8)), closes [#14001](https://github.com/angular/angular/issues/14001)
|
* **core:** export animation classes required for Renderer impl ([#14002](https://github.com/angular/angular/issues/14002)) ([83361d8](https://github.com/angular/angular/commit/83361d8)), closes [#14001](https://github.com/angular/angular/issues/14001)
|
||||||
* **core:** fix not declared variable in view engine ([#14045](https://github.com/angular/angular/issues/14045)) ([d3a3a8e](https://github.com/angular/angular/commit/d3a3a8e))
|
* **core:** fix not declared variable in view engine ([#14045](https://github.com/angular/angular/issues/14045)) ([d3a3a8e](https://github.com/angular/angular/commit/d3a3a8e))
|
||||||
|
* **http:** don't create a blob out of ArrayBuffer when type is application/octet-stream ([#13992](https://github.com/angular/angular/issues/13992)) ([1200cf2](https://github.com/angular/angular/commit/1200cf2)), closes [#13973](https://github.com/angular/angular/issues/13973)
|
||||||
|
* **router:** enable loadChildren with function in aot ([#13909](https://github.com/angular/angular/issues/13909)) ([635bf02](https://github.com/angular/angular/commit/635bf02)), closes [#11075](https://github.com/angular/angular/issues/11075)
|
||||||
|
* **router:** routerLinkActive should not throw when not initialized ([#13273](https://github.com/angular/angular/issues/13273)) ([e8ea741](https://github.com/angular/angular/commit/e8ea741)), closes [#13270](https://github.com/angular/angular/issues/13270)
|
||||||
|
* **upgrade:** detect async downgrade component changes ([#13812](https://github.com/angular/angular/issues/13812)) ([d6382bf](https://github.com/angular/angular/commit/d6382bf)), closes [#6385](https://github.com/angular/angular/issues/6385) [#6385](https://github.com/angular/angular/issues/6385) [#10660](https://github.com/angular/angular/issues/10660) [#12318](https://github.com/angular/angular/issues/12318) [#12034](https://github.com/angular/angular/issues/12034)
|
||||||
* **upgrade/static:** ensure upgraded injector is initialized early enough ([#14065](https://github.com/angular/angular/issues/14065)) ([6152eb2](https://github.com/angular/angular/commit/6152eb2)), closes [#13811](https://github.com/angular/angular/issues/13811)
|
* **upgrade/static:** ensure upgraded injector is initialized early enough ([#14065](https://github.com/angular/angular/issues/14065)) ([6152eb2](https://github.com/angular/angular/commit/6152eb2)), closes [#13811](https://github.com/angular/angular/issues/13811)
|
||||||
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
|
* **build:** optionally build an ES2015 distro ([#13471](https://github.com/angular/angular/issues/13471)) ([be6c95a](https://github.com/angular/angular/commit/be6c95a))
|
||||||
* **core:** add event support to view engine ([0adb97b](https://github.com/angular/angular/commit/0adb97b))
|
* **core:** add event support to view engine ([0adb97b](https://github.com/angular/angular/commit/0adb97b))
|
||||||
* **core:** add initial view engine ([#14014](https://github.com/angular/angular/issues/14014)) ([2f87eb5](https://github.com/angular/angular/commit/2f87eb5))
|
* **core:** add initial view engine ([#14014](https://github.com/angular/angular/issues/14014)) ([2f87eb5](https://github.com/angular/angular/commit/2f87eb5))
|
||||||
* **core:** add pure expression support to view engine ([6541737](https://github.com/angular/angular/commit/6541737))
|
* **core:** add pure expression support to view engine ([6541737](https://github.com/angular/angular/commit/6541737))
|
||||||
|
* **core:** Add type information to injector.get() ([#13785](https://github.com/angular/angular/issues/13785)) ([d169c24](https://github.com/angular/angular/commit/d169c24))
|
||||||
|
* **security:** allow calc and gradient functions. ([#13943](https://github.com/angular/angular/issues/13943)) ([e19bf70](https://github.com/angular/angular/commit/e19bf70))
|
||||||
* **tsc-wrapped:** Support of vinyl like config file was added ([#13987](https://github.com/angular/angular/issues/13987)) ([0c7726d](https://github.com/angular/angular/commit/0c7726d))
|
* **tsc-wrapped:** Support of vinyl like config file was added ([#13987](https://github.com/angular/angular/issues/13987)) ([0c7726d](https://github.com/angular/angular/commit/0c7726d))
|
||||||
* **upgrade:** Support ng-model in downgraded components ([#10578](https://github.com/angular/angular/issues/10578)) ([e21e9c5](https://github.com/angular/angular/commit/e21e9c5))
|
* **upgrade:** Support ng-model in downgraded components ([#10578](https://github.com/angular/angular/issues/10578)) ([e21e9c5](https://github.com/angular/angular/commit/e21e9c5))
|
||||||
|
|
||||||
@ -5850,12 +5914,19 @@ Note: The 2.3.0-beta.0 release also contains all the changes present in the 2.2.
|
|||||||
|
|
||||||
### Features (summary of all features from 2.2.0-beta.0 - 2.2.0-rc.0 releases)
|
### Features (summary of all features from 2.2.0-beta.0 - 2.2.0-rc.0 releases)
|
||||||
|
|
||||||
|
* **common:** support narrow forms for month and weekdays in DatePipe ([#12297](https://github.com/angular/angular/issues/12297)) ([f77ab6a](https://github.com/angular/angular/commit/f77ab6a)), closes [#12294](https://github.com/angular/angular/issues/12294)
|
||||||
* **core:** map 'for' attribute to 'htmlFor' property ([#10546](https://github.com/angular/angular/issues/10546)) ([634b3bb](https://github.com/angular/angular/commit/634b3bb)), closes [#7516](https://github.com/angular/angular/issues/7516)
|
* **core:** map 'for' attribute to 'htmlFor' property ([#10546](https://github.com/angular/angular/issues/10546)) ([634b3bb](https://github.com/angular/angular/commit/634b3bb)), closes [#7516](https://github.com/angular/angular/issues/7516)
|
||||||
* **core:** add the find method to QueryList ([7c16ef9](https://github.com/angular/angular/commit/7c16ef9))
|
* **core:** add the find method to QueryList ([7c16ef9](https://github.com/angular/angular/commit/7c16ef9))
|
||||||
|
* **forms:** add hasError and getError to AbstractControlDirective ([#11985](https://github.com/angular/angular/issues/11985)) ([592f40a](https://github.com/angular/angular/commit/592f40a)), closes [#7255](https://github.com/angular/angular/issues/7255)
|
||||||
|
* **forms:** add ng-pending CSS class during async validation ([#11243](https://github.com/angular/angular/issues/11243)) ([97bc971](https://github.com/angular/angular/commit/97bc971)), closes [#10336](https://github.com/angular/angular/issues/10336)
|
||||||
* **forms:** add emitEvent to AbstractControl methods ([#11949](https://github.com/angular/angular/issues/11949)) ([b9fc090](https://github.com/angular/angular/commit/b9fc090))
|
* **forms:** add emitEvent to AbstractControl methods ([#11949](https://github.com/angular/angular/issues/11949)) ([b9fc090](https://github.com/angular/angular/commit/b9fc090))
|
||||||
|
* **forms:** make 'parent' a public property of 'AbstractControl' ([#11855](https://github.com/angular/angular/issues/11855)) ([445e592](https://github.com/angular/angular/commit/445e592))
|
||||||
|
* **forms:** Validator.pattern accepts a RegExp ([#12323](https://github.com/angular/angular/issues/12323)) ([bf60418](https://github.com/angular/angular/commit/bf60418))
|
||||||
* **router:** add a provider making angular1/angular2 integration easier ([#12769](https://github.com/angular/angular/issues/12769)) ([6e35d13](https://github.com/angular/angular/commit/6e35d13))
|
* **router:** add a provider making angular1/angular2 integration easier ([#12769](https://github.com/angular/angular/issues/12769)) ([6e35d13](https://github.com/angular/angular/commit/6e35d13))
|
||||||
* **router:** add support for custom url matchers ([7340735](https://github.com/angular/angular/commit/7340735)), closes [#12442](https://github.com/angular/angular/issues/12442) [#12772](https://github.com/angular/angular/issues/12772)
|
* **router:** add support for custom url matchers ([7340735](https://github.com/angular/angular/commit/7340735)), closes [#12442](https://github.com/angular/angular/issues/12442) [#12772](https://github.com/angular/angular/issues/12772)
|
||||||
* **router:** export routerLinkActive w/ isActive property ([c9f58cf](https://github.com/angular/angular/commit/c9f58cf))
|
* **router:** export routerLinkActive w/ isActive property ([c9f58cf](https://github.com/angular/angular/commit/c9f58cf))
|
||||||
|
* **router:** add support for ng1/ng2 migration ([#12160](https://github.com/angular/angular/issues/12160)) ([8b9ab44](https://github.com/angular/angular/commit/8b9ab44))
|
||||||
|
* **upgrade:** add support for AoT compiled upgrade applications ([d6791ff](https://github.com/angular/angular/commit/d6791ff)), closes [#12239](https://github.com/angular/angular/issues/12239)
|
||||||
* **upgrade:** add support for `require` in UpgradeComponent ([fe1d0e2](https://github.com/angular/angular/commit/fe1d0e2))
|
* **upgrade:** add support for `require` in UpgradeComponent ([fe1d0e2](https://github.com/angular/angular/commit/fe1d0e2))
|
||||||
* **upgrade:** add/improve support for lifecycle hooks in UpgradeComponent ([469010e](https://github.com/angular/angular/commit/469010e))
|
* **upgrade:** add/improve support for lifecycle hooks in UpgradeComponent ([469010e](https://github.com/angular/angular/commit/469010e))
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# CLI Overview and Command Reference
|
# CLI Overview and Command Reference
|
||||||
|
|
||||||
The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications. You can use the tool directly in a command shell, or indirectly through an interactive UI such as [Angular Console](https://angularconsole.com).
|
The Angular CLI is a command-line interface tool that you use to initialize, develop, scaffold, and maintain Angular applications directly from a command shell.
|
||||||
|
|
||||||
## Installing Angular CLI
|
## Installing Angular CLI
|
||||||
|
|
||||||
|
1
aio/content/examples/.gitignore
vendored
1
aio/content/examples/.gitignore
vendored
@ -18,6 +18,7 @@
|
|||||||
**/src/karma.conf.js
|
**/src/karma.conf.js
|
||||||
**/.angular-cli.json
|
**/.angular-cli.json
|
||||||
**/.editorconfig
|
**/.editorconfig
|
||||||
|
**/.gitignore
|
||||||
**/angular.json
|
**/angular.json
|
||||||
**/tsconfig.json
|
**/tsconfig.json
|
||||||
**/bs-config.e2e.json
|
**/bs-config.e2e.json
|
||||||
|
@ -16,5 +16,12 @@
|
|||||||
"@angular/core": "^7.2.0"
|
"@angular/core": "^7.2.0"
|
||||||
},
|
},
|
||||||
// #docregion collection
|
// #docregion collection
|
||||||
"schematics": "./schematics/collection.json"
|
"schematics": "./schematics/collection.json",
|
||||||
|
// #enddocregion collection
|
||||||
|
// #docregion ng-add
|
||||||
|
"ng-add": {
|
||||||
|
"save": "devDependencies"
|
||||||
|
}
|
||||||
|
// #enddocregion ng-add
|
||||||
|
// #docregion collection
|
||||||
}
|
}
|
@ -11,7 +11,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
<script src="systemjs.config.js"></script>
|
<script src="systemjs.config.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<!-- Polyfills -->
|
<!-- Polyfills -->
|
||||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||||
|
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||||
|
|
||||||
<script src="systemjs.config.1.js"></script>
|
<script src="systemjs.config.1.js"></script>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<script src="phone-detail/phone-detail.module.js"></script>
|
<script src="phone-detail/phone-detail.module.js"></script>
|
||||||
|
|
||||||
<script src="/node_modules/core-js/client/shim.min.js"></script>
|
<script src="/node_modules/core-js/client/shim.min.js"></script>
|
||||||
<script src="/node_modules/zone.js/bundles/zone.umd.min.js"></script>
|
<script src="/node_modules/zone.js/dist/zone.min.js"></script>
|
||||||
|
|
||||||
<script>window.module = 'aot';</script>
|
<script>window.module = 'aot';</script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -3,7 +3,7 @@ var fsExtra = require('fs-extra');
|
|||||||
var resources = [
|
var resources = [
|
||||||
// polyfills
|
// polyfills
|
||||||
'node_modules/core-js/client/shim.min.js',
|
'node_modules/core-js/client/shim.min.js',
|
||||||
'node_modules/zone.js/bundles/zone.umd.min.js',
|
'node_modules/zone.js/dist/zone.min.js',
|
||||||
// css
|
// css
|
||||||
'app/app.css',
|
'app/app.css',
|
||||||
'app/app.animations.css',
|
'app/app.animations.css',
|
||||||
@ -20,7 +20,6 @@ var resources = [
|
|||||||
'app/phone-detail/phone-detail.module.js'
|
'app/phone-detail/phone-detail.module.js'
|
||||||
];
|
];
|
||||||
resources.map(function(sourcePath) {
|
resources.map(function(sourcePath) {
|
||||||
// Need to rename zone.umd.min.js to zone.min.js
|
var destPath = `aot/${sourcePath}`;
|
||||||
var destPath = `aot/${sourcePath}`.replace('.umd.min.js', '.min.js');
|
|
||||||
fsExtra.copySync(sourcePath, destPath);
|
fsExtra.copySync(sourcePath, destPath);
|
||||||
});
|
});
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
<!-- #docregion angular -->
|
<!-- #docregion angular -->
|
||||||
<script src="/node_modules/core-js/client/shim.min.js"></script>
|
<script src="/node_modules/core-js/client/shim.min.js"></script>
|
||||||
<script src="/node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="/node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="/node_modules/systemjs/dist/system.src.js"></script>
|
<script src="/node_modules/systemjs/dist/system.src.js"></script>
|
||||||
<!-- #enddocregion angular -->
|
<!-- #enddocregion angular -->
|
||||||
<script src="/systemjs.config.1.js"></script>
|
<script src="/systemjs.config.1.js"></script>
|
||||||
|
@ -21,8 +21,8 @@ module.exports = function(config) {
|
|||||||
'node_modules/core-js/client/shim.js',
|
'node_modules/core-js/client/shim.js',
|
||||||
|
|
||||||
// zone.js
|
// zone.js
|
||||||
'node_modules/zone.js/bundles/zone.umd.js',
|
'node_modules/zone.js/dist/zone.js',
|
||||||
'node_modules/zone.js/bundles/zone-testing.umd.js',
|
'node_modules/zone.js/dist/zone-testing.js',
|
||||||
|
|
||||||
// RxJs.
|
// RxJs.
|
||||||
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
||||||
|
@ -31,8 +31,8 @@ module.exports = function(config) {
|
|||||||
'node_modules/core-js/client/shim.js',
|
'node_modules/core-js/client/shim.js',
|
||||||
|
|
||||||
// zone.js
|
// zone.js
|
||||||
'node_modules/zone.js/bundles/zone.umd.js',
|
'node_modules/zone.js/dist/zone.js',
|
||||||
'node_modules/zone.js/bundles/zone-testing.umd.js',
|
'node_modules/zone.js/dist/zone-testing.js',
|
||||||
|
|
||||||
// RxJs
|
// RxJs
|
||||||
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<link rel="stylesheet" href="app.css" />
|
<link rel="stylesheet" href="app.css" />
|
||||||
|
|
||||||
<script src="/node_modules/core-js/client/shim.min.js"></script>
|
<script src="/node_modules/core-js/client/shim.min.js"></script>
|
||||||
<script src="/node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="/node_modules/zone.js/dist/zone.js"></script>
|
||||||
<script src="/node_modules/systemjs/dist/system.src.js"></script>
|
<script src="/node_modules/systemjs/dist/system.src.js"></script>
|
||||||
<!-- #enddocregion full -->
|
<!-- #enddocregion full -->
|
||||||
<script src="/systemjs.config.1.js"></script>
|
<script src="/systemjs.config.1.js"></script>
|
||||||
|
@ -31,8 +31,8 @@ module.exports = function(config) {
|
|||||||
'node_modules/core-js/client/shim.js',
|
'node_modules/core-js/client/shim.js',
|
||||||
|
|
||||||
// zone.js
|
// zone.js
|
||||||
'node_modules/zone.js/bundles/zone.umd.js',
|
'node_modules/zone.js/dist/zone.js',
|
||||||
'node_modules/zone.js/bundles/zone-testing.umd.js',
|
'node_modules/zone.js/dist/zone-testing.js',
|
||||||
|
|
||||||
// RxJs
|
// RxJs
|
||||||
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
|
||||||
|
@ -20,7 +20,7 @@ work well for all users, including those who rely on assistive technologies.
|
|||||||
|
|
||||||
Building accessible web experience often involves setting [ARIA attributes](https://developers.google.com/web/fundamentals/accessibility/semantics-aria)
|
Building accessible web experience often involves setting [ARIA attributes](https://developers.google.com/web/fundamentals/accessibility/semantics-aria)
|
||||||
to provide semantic meaning where it might otherwise be missing.
|
to provide semantic meaning where it might otherwise be missing.
|
||||||
Use [attribute binding](guide/template-syntax#attribute-binding) template syntax to control the values of accessibility-related attributes.
|
Use [attribute binding](guide/attribute-binding) template syntax to control the values of accessibility-related attributes.
|
||||||
|
|
||||||
When binding to ARIA attributes in Angular, you must use the `attr.` prefix, as the ARIA
|
When binding to ARIA attributes in Angular, you must use the `attr.` prefix, as the ARIA
|
||||||
specification depends specifically on HTML attributes rather than properties of DOM elements.
|
specification depends specifically on HTML attributes rather than properties of DOM elements.
|
||||||
@ -44,7 +44,7 @@ NOTE:
|
|||||||
|
|
||||||
By convention, HTML attributes use lowercase names (`tabindex`), while properties use camelCase names (`tabIndex`).
|
By convention, HTML attributes use lowercase names (`tabindex`), while properties use camelCase names (`tabIndex`).
|
||||||
|
|
||||||
See the [Template Syntax](guide/template-syntax#html-attribute-vs-dom-property) guide for more background on the difference between attributes and properties.
|
See the [Binding syntax](guide/binding-syntax#html-attribute-vs-dom-property) guide for more background on the difference between attributes and properties.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -74,8 +74,7 @@ The following table lists some of the key AngularJS template features with their
|
|||||||
The context of the binding is implied and is always the
|
The context of the binding is implied and is always the
|
||||||
associated component, so it needs no reference variable.
|
associated component, so it needs no reference variable.
|
||||||
|
|
||||||
For more information, see the [Interpolation](guide/template-syntax#interpolation)
|
For more information, see the [Interpolation](guide/interpolation) guide.
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -141,8 +140,8 @@ The following table lists some of the key AngularJS template features with their
|
|||||||
|
|
||||||
Angular has true template input variables that are explicitly defined using the `let` keyword.
|
Angular has true template input variables that are explicitly defined using the `let` keyword.
|
||||||
|
|
||||||
For more information, see the [ngFor micro-syntax](guide/template-syntax#microsyntax)
|
For more information, see the [ngFor micro-syntax](guide/built-in-directives#microsyntax)
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
section of the [Built-in Directives](guide/built-in-directives) page.
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -258,8 +257,7 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
Angular also has **class binding**, which is a good way to add or remove a single class,
|
Angular also has **class binding**, which is a good way to add or remove a single class,
|
||||||
as shown in the third example.
|
as shown in the third example.
|
||||||
|
|
||||||
For more information see the [Attribute, class, and style bindings](guide/template-syntax#other-bindings)
|
For more information see [Attribute, class, and style bindings](guide/attribute-binding) page.
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@ -309,8 +307,7 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
|
|
||||||
For a list of DOM events, see: https://developer.mozilla.org/en-US/docs/Web/Events.
|
For a list of DOM events, see: https://developer.mozilla.org/en-US/docs/Web/Events.
|
||||||
|
|
||||||
For more information, see the [Event binding](guide/template-syntax#event-binding)
|
For more information, see the [Event binding](guide/event-binding) page.
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
@ -407,8 +404,7 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
Angular uses property binding; there is no built-in *href* directive.
|
Angular uses property binding; there is no built-in *href* directive.
|
||||||
Place the element's `href` property in square brackets and set it to a quoted template expression.
|
Place the element's `href` property in square brackets and set it to a quoted template expression.
|
||||||
|
|
||||||
For more information see the [Property binding](guide/template-syntax#property-binding)
|
For more information see the [Property binding](guide/property-binding) page.
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
|
||||||
|
|
||||||
In Angular, `href` is no longer used for routing. Routing uses `routerLink`, as shown in the following example.
|
In Angular, `href` is no longer used for routing. Routing uses `routerLink`, as shown in the following example.
|
||||||
|
|
||||||
@ -487,8 +483,8 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
and event binding (from the view to the component), thereby providing two-way binding.
|
and event binding (from the view to the component), thereby providing two-way binding.
|
||||||
|
|
||||||
For more information on two-way binding with `ngModel`, see the [NgModel—Two-way binding to
|
For more information on two-way binding with `ngModel`, see the [NgModel—Two-way binding to
|
||||||
form elements with `[(ngModel)]`](../guide/template-syntax.html#ngModel)
|
form elements with `[(ngModel)]`](../guide/built-in-directives#ngModel)
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
section of the [Built-in directives](guide/built-in-directives) page.
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -570,8 +566,7 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
|
|
||||||
In this example, the `<div>` element is hidden if the `favoriteHero` variable is not truthy.
|
In this example, the `<div>` element is hidden if the `favoriteHero` variable is not truthy.
|
||||||
|
|
||||||
For more information on property binding, see the [Property binding](guide/template-syntax#property-binding)
|
For more information on property binding, see the [Property binding](guide/property-binding) page.
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -604,8 +599,7 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
Angular uses property binding; there is no built-in *src* directive.
|
Angular uses property binding; there is no built-in *src* directive.
|
||||||
Place the `src` property in square brackets and set it to a quoted template expression.
|
Place the `src` property in square brackets and set it to a quoted template expression.
|
||||||
|
|
||||||
For more information on property binding, see the [Property binding](guide/template-syntax#property-binding)
|
For more information on property binding, see the [Property binding](guide/property-binding) page.
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -644,11 +638,11 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
|
|
||||||
Angular also has **style binding**, which is good way to set a single style. This is shown in the second example.
|
Angular also has **style binding**, which is good way to set a single style. This is shown in the second example.
|
||||||
|
|
||||||
For more information on style binding, see the [Style binding](guide/template-syntax#style-binding) section of the
|
For more information on style binding, see the [Style binding](guide/attribute-binding#style-binding) section of the
|
||||||
[Template Syntax](guide/template-syntax) page.
|
[Attribute binding](guide/attribute-binding) page.
|
||||||
|
|
||||||
For more information on the `ngStyle` directive, see [NgStyle](guide/template-syntax#ngStyle)
|
For more information on the `ngStyle` directive, see the [NgStyle](guide/built-in-directives#ngStyle)
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
section of the [Built-in directives](guide/built-in-directives) page.
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -704,8 +698,8 @@ The following are some of the key AngularJS built-in directives and their equiva
|
|||||||
|
|
||||||
The (*) before `ngSwitchCase` and `ngSwitchDefault` is required in this example.
|
The (*) before `ngSwitchCase` and `ngSwitchDefault` is required in this example.
|
||||||
|
|
||||||
For more information, see [The NgSwitch directives](guide/template-syntax#ngSwitch)
|
For more information, see [The NgSwitch directives](guide/built-in-directives#ngSwitch)
|
||||||
section of the [Template Syntax](guide/template-syntax) page.
|
section of the [Built-in directives](guide/built-in-directives) page.
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -186,7 +186,7 @@ For library projects generated with the CLI, the dev configuration default is `t
|
|||||||
|
|
||||||
When `true` (recommended), reports an error for a supplied parameter whose injection type cannot be determined. When `false` (currently the default), constructor parameters of classes marked with `@Injectable` whose type cannot be resolved produce a warning.
|
When `true` (recommended), reports an error for a supplied parameter whose injection type cannot be determined. When `false` (currently the default), constructor parameters of classes marked with `@Injectable` whose type cannot be resolved produce a warning.
|
||||||
|
|
||||||
When you use the CLI command `ng new`, it is set to `true` by default in the generated project's configuration.
|
When you use the CLI command `ng new --strict`, it is set to `true` in the generated project's configuration.
|
||||||
|
|
||||||
### `strictTemplates`
|
### `strictTemplates`
|
||||||
|
|
||||||
@ -194,6 +194,7 @@ When `true`, enables [strict template type checking](guide/template-typecheck#st
|
|||||||
|
|
||||||
Additional strictness flags allow you to enable and disable specific types of strict template type checking. See [troubleshooting template errors](guide/template-typecheck#troubleshooting-template-errors).
|
Additional strictness flags allow you to enable and disable specific types of strict template type checking. See [troubleshooting template errors](guide/template-typecheck#troubleshooting-template-errors).
|
||||||
|
|
||||||
|
When you use the CLI command `ng new --strict`, it is set to `true` in the generated project's configuration.
|
||||||
|
|
||||||
### `trace`
|
### `trace`
|
||||||
|
|
||||||
|
@ -623,7 +623,7 @@ For more information about input type narrowing, see [Input setter coercion](gui
|
|||||||
|
|
||||||
### Non-null type assertion operator
|
### Non-null type assertion operator
|
||||||
|
|
||||||
Use the [non-null type assertion operator](guide/template-syntax#non-null-assertion-operator) to suppress the `Object is possibly 'undefined'` error when it is inconvenient to use `*ngIf` or when some constraint in the component ensures that the expression is always non-null when the binding expression is interpolated.
|
Use the [non-null type assertion operator](guide/template-expression-operators#non-null-assertion-operator) to suppress the `Object is possibly 'undefined'` error when it is inconvenient to use `*ngIf` or when some constraint in the component ensures that the expression is always non-null when the binding expression is interpolated.
|
||||||
|
|
||||||
In the following example, the `person` and `address` properties are always set together, implying that `address` is always non-null if `person` is non-null.
|
In the following example, the `person` and `address` properties are always set together, implying that `address` is always non-null if `person` is non-null.
|
||||||
There is no convenient way to describe this constraint to TypeScript and the template compiler, but the error is suppressed in the example by using `address!.street`.
|
There is no convenient way to describe this constraint to TypeScript and the template compiler, but the error is suppressed in the example by using `address!.street`.
|
||||||
|
@ -430,7 +430,7 @@ Angular does something similar with the `DOCUMENT` token so you can inject the b
|
|||||||
|
|
||||||
```ts
|
```ts
|
||||||
import { Inject } from '@angular/core';
|
import { Inject } from '@angular/core';
|
||||||
import { DOCUMENT } from '@angular/platform-browser';
|
import { DOCUMENT } from '@angular/common';
|
||||||
|
|
||||||
@Component({ ... })
|
@Component({ ... })
|
||||||
export class MyComponent {
|
export class MyComponent {
|
||||||
|
@ -92,7 +92,7 @@ This example from the `HeroListComponent` template uses three of these forms.
|
|||||||
* The `{{hero.name}}` [*interpolation*](guide/displaying-data#interpolation)
|
* The `{{hero.name}}` [*interpolation*](guide/displaying-data#interpolation)
|
||||||
displays the component's `hero.name` property value within the `<li>` element.
|
displays the component's `hero.name` property value within the `<li>` element.
|
||||||
|
|
||||||
* The `[hero]` [*property binding*](guide/template-syntax#property-binding) passes the value of
|
* The `[hero]` [*property binding*](guide/property-binding) passes the value of
|
||||||
`selectedHero` from the parent `HeroListComponent` to the `hero` property of the child `HeroDetailComponent`.
|
`selectedHero` from the parent `HeroListComponent` to the `hero` property of the child `HeroDetailComponent`.
|
||||||
|
|
||||||
* The `(click)` [*event binding*](guide/user-input#binding-to-user-input-events) calls the component's `selectHero` method when the user clicks a hero's name.
|
* The `(click)` [*event binding*](guide/user-input#binding-to-user-input-events) calls the component's `selectHero` method when the user clicks a hero's name.
|
||||||
@ -126,7 +126,7 @@ Angular pipes let you declare display-value transformations in your template HTM
|
|||||||
|
|
||||||
Angular defines various pipes, such as the [date](https://angular.io/api/common/DatePipe) pipe and [currency](https://angular.io/api/common/CurrencyPipe) pipe; for a complete list, see the [Pipes API list](https://angular.io/api?type=pipe). You can also define new pipes.
|
Angular defines various pipes, such as the [date](https://angular.io/api/common/DatePipe) pipe and [currency](https://angular.io/api/common/CurrencyPipe) pipe; for a complete list, see the [Pipes API list](https://angular.io/api?type=pipe). You can also define new pipes.
|
||||||
|
|
||||||
To specify a value transformation in an HTML template, use the [pipe operator (|)](https://angular.io/guide/template-syntax#pipe).
|
To specify a value transformation in an HTML template, use the [pipe operator (|)](https://angular.io/guide/template-expression-operators#pipe).
|
||||||
|
|
||||||
`{{interpolated_value | pipe_name}}`
|
`{{interpolated_value | pipe_name}}`
|
||||||
|
|
||||||
@ -179,9 +179,9 @@ The `ngModel` directive, which implements two-way data binding, is an example of
|
|||||||
<code-example path="architecture/src/app/hero-detail.component.html" header="src/app/hero-detail.component.html (ngModel)" region="ngModel"></code-example>
|
<code-example path="architecture/src/app/hero-detail.component.html" header="src/app/hero-detail.component.html (ngModel)" region="ngModel"></code-example>
|
||||||
|
|
||||||
Angular has more pre-defined directives that either alter the layout structure
|
Angular has more pre-defined directives that either alter the layout structure
|
||||||
(for example, [ngSwitch](guide/template-syntax#ngSwitch))
|
(for example, [ngSwitch](guide/built-in-directives#ngSwitch))
|
||||||
or modify aspects of DOM elements and components
|
or modify aspects of DOM elements and components
|
||||||
(for example, [ngStyle](guide/template-syntax#ngStyle) and [ngClass](guide/template-syntax#ngClass)).
|
(for example, [ngStyle](guide/built-in-directives#ngStyle) and [ngClass](guide/built-in-directives#ngClass)).
|
||||||
|
|
||||||
<div class="alert is-helpful">
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
303
aio/content/guide/attribute-binding.md
Normal file
303
aio/content/guide/attribute-binding.md
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
# Attribute, class, and style bindings
|
||||||
|
|
||||||
|
The template syntax provides specialized one-way bindings for scenarios less well-suited to property binding.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
## Attribute binding
|
||||||
|
|
||||||
|
Set the value of an attribute directly with an **attribute binding**. This is the only exception to the rule that a binding sets a target property and the only binding that creates and sets an attribute.
|
||||||
|
|
||||||
|
Usually, setting an element property with a [property binding](guide/property-binding)
|
||||||
|
is preferable to setting the attribute with a string. However, sometimes
|
||||||
|
there is no element property to bind, so attribute binding is the solution.
|
||||||
|
|
||||||
|
Consider the [ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) and
|
||||||
|
[SVG](https://developer.mozilla.org/en-US/docs/Web/SVG). They are purely attributes, don't correspond to element properties, and don't set element properties. In these cases, there are no property targets to bind to.
|
||||||
|
|
||||||
|
Attribute binding syntax resembles property binding, but
|
||||||
|
instead of an element property between brackets, start with the prefix `attr`,
|
||||||
|
followed by a dot (`.`), and the name of the attribute.
|
||||||
|
You then set the attribute value, using an expression that resolves to a string,
|
||||||
|
or remove the attribute when the expression resolves to `null`.
|
||||||
|
|
||||||
|
One of the primary use cases for attribute binding
|
||||||
|
is to set ARIA attributes, as in this example:
|
||||||
|
|
||||||
|
<code-example path="attribute-binding/src/app/app.component.html" region="attrib-binding-aria" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
{@a colspan}
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
#### `colspan` and `colSpan`
|
||||||
|
|
||||||
|
Notice the difference between the `colspan` attribute and the `colSpan` property.
|
||||||
|
|
||||||
|
If you wrote something like this:
|
||||||
|
|
||||||
|
<code-example language="html">
|
||||||
|
<tr><td colspan="{{1 + 1}}">Three-Four</td></tr>
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
You'd get this error:
|
||||||
|
|
||||||
|
<code-example language="bash">
|
||||||
|
Template parse errors:
|
||||||
|
Can't bind to 'colspan' since it isn't a known native property
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
As the message says, the `<td>` element does not have a `colspan` property. This is true
|
||||||
|
because `colspan` is an attribute—`colSpan`, with a capital `S`, is the
|
||||||
|
corresponding property. Interpolation and property binding can set only *properties*, not attributes.
|
||||||
|
|
||||||
|
Instead, you'd use property binding and write it like this:
|
||||||
|
|
||||||
|
<code-example path="attribute-binding/src/app/app.component.html" region="colSpan" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a class-binding}
|
||||||
|
|
||||||
|
## Class binding
|
||||||
|
|
||||||
|
Here's how to set the `class` attribute without a binding in plain HTML:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- standard class attribute setting -->
|
||||||
|
<div class="foo bar">Some text</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also add and remove CSS class names from an element's `class` attribute with a **class binding**.
|
||||||
|
|
||||||
|
To create a single class binding, start with the prefix `class` followed by a dot (`.`) and the name of the CSS class (for example, `[class.foo]="hasFoo"`).
|
||||||
|
Angular adds the class when the bound expression is truthy, and it removes the class when the expression is falsy (with the exception of `undefined`, see [styling delegation](#styling-delegation)).
|
||||||
|
|
||||||
|
To create a binding to multiple classes, use a generic `[class]` binding without the dot (for example, `[class]="classExpr"`).
|
||||||
|
The expression can be a space-delimited string of class names, or you can format it as an object with class names as the keys and truthy/falsy expressions as the values.
|
||||||
|
With object format, Angular will add a class only if its associated value is truthy.
|
||||||
|
|
||||||
|
It's important to note that with any object-like expression (`object`, `Array`, `Map`, `Set`, etc), the identity of the object must change for the class list to be updated.
|
||||||
|
Updating the property without changing object identity will have no effect.
|
||||||
|
|
||||||
|
If there are multiple bindings to the same class name, conflicts are resolved using [styling precedence](#styling-precedence).
|
||||||
|
|
||||||
|
<style>
|
||||||
|
td, th {vertical-align: top}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<col width="15%">
|
||||||
|
</col>
|
||||||
|
<col width="20%">
|
||||||
|
</col>
|
||||||
|
<col width="35%">
|
||||||
|
</col>
|
||||||
|
<col width="30%">
|
||||||
|
</col>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Binding Type
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Syntax
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Input Type
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Example Input Values
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Single class binding</td>
|
||||||
|
<td><code>[class.foo]="hasFoo"</code></td>
|
||||||
|
<td><code>boolean | undefined | null</code></td>
|
||||||
|
<td><code>true</code>, <code>false</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td rowspan=3>Multi-class binding</td>
|
||||||
|
<td rowspan=3><code>[class]="classExpr"</code></td>
|
||||||
|
<td><code>string</code></td>
|
||||||
|
<td><code>"my-class-1 my-class-2 my-class-3"</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>{[key: string]: boolean | undefined | null}</code></td>
|
||||||
|
<td><code>{foo: true, bar: false}</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>Array</code><<code>string</code>></td>
|
||||||
|
<td><code>['foo', 'bar']</code></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
The [NgClass](guide/built-in-directives/#ngclass) directive can be used as an alternative to direct `[class]` bindings.
|
||||||
|
However, using the above class binding syntax without `NgClass` is preferred because due to improvements in class binding in Angular, `NgClass` no longer provides significant value, and might eventually be removed in the future.
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
## Style binding
|
||||||
|
|
||||||
|
Here's how to set the `style` attribute without a binding in plain HTML:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- standard style attribute setting -->
|
||||||
|
<div style="color: blue">Some text</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also set styles dynamically with a **style binding**.
|
||||||
|
|
||||||
|
To create a single style binding, start with the prefix `style` followed by a dot (`.`) and the name of the CSS style property (for example, `[style.width]="width"`).
|
||||||
|
The property will be set to the value of the bound expression, which is normally a string.
|
||||||
|
Optionally, you can add a unit extension like `em` or `%`, which requires a number type.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Note that a _style property_ name can be written in either
|
||||||
|
[dash-case](guide/glossary#dash-case), as shown above, or
|
||||||
|
[camelCase](guide/glossary#camelcase), such as `fontSize`.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
If there are multiple styles you'd like to toggle, you can bind to the `[style]` property directly without the dot (for example, `[style]="styleExpr"`).
|
||||||
|
The expression attached to the `[style]` binding is most often a string list of styles like `"width: 100px; height: 100px;"`.
|
||||||
|
|
||||||
|
You can also format the expression as an object with style names as the keys and style values as the values, like `{width: '100px', height: '100px'}`.
|
||||||
|
It's important to note that with any object-like expression (`object`, `Array`, `Map`, `Set`, etc), the identity of the object must change for the class list to be updated.
|
||||||
|
Updating the property without changing object identity will have no effect.
|
||||||
|
|
||||||
|
If there are multiple bindings to the same style property, conflicts are resolved using [styling precedence rules](#styling-precedence).
|
||||||
|
|
||||||
|
<style>
|
||||||
|
td, th {vertical-align: top}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<col width="15%">
|
||||||
|
</col>
|
||||||
|
<col width="20%">
|
||||||
|
</col>
|
||||||
|
<col width="35%">
|
||||||
|
</col>
|
||||||
|
<col width="30%">
|
||||||
|
</col>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Binding Type
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Syntax
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Input Type
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Example Input Values
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Single style binding</td>
|
||||||
|
<td><code>[style.width]="width"</code></td>
|
||||||
|
<td><code>string | undefined | null</code></td>
|
||||||
|
<td><code>"100px"</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<tr>
|
||||||
|
<td>Single style binding with units</td>
|
||||||
|
<td><code>[style.width.px]="width"</code></td>
|
||||||
|
<td><code>number | undefined | null</code></td>
|
||||||
|
<td><code>100</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td rowspan=3>Multi-style binding</td>
|
||||||
|
<td rowspan=3><code>[style]="styleExpr"</code></td>
|
||||||
|
<td><code>string</code></td>
|
||||||
|
<td><code>"width: 100px; height: 100px"</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>{[key: string]: string | undefined | null}</code></td>
|
||||||
|
<td><code>{width: '100px', height: '100px'}</code></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>Array</code><<code>string</code>></td>
|
||||||
|
<td><code>['width', '100px']</code></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
The [NgStyle](guide/built-in-directives/#ngstyle) directive can be used as an alternative to direct `[style]` bindings.
|
||||||
|
However, using the above style binding syntax without `NgStyle` is preferred because due to improvements in style binding in Angular, `NgStyle` no longer provides significant value, and might eventually be removed in the future.
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a styling-precedence}
|
||||||
|
|
||||||
|
## Styling Precedence
|
||||||
|
|
||||||
|
A single HTML element can have its CSS class list and style values bound to multiple sources (for example, host bindings from multiple directives).
|
||||||
|
|
||||||
|
When there are multiple bindings to the same class name or style property, Angular uses a set of precedence rules to resolve conflicts and determine which classes or styles are ultimately applied to the element.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
<h4>Styling precedence (highest to lowest)</h4>
|
||||||
|
|
||||||
|
1. Template bindings
|
||||||
|
1. Property binding (for example, `<div [class.foo]="hasFoo">` or `<div [style.color]="color">`)
|
||||||
|
1. Map binding (for example, `<div [class]="classExpr">` or `<div [style]="styleExpr">`)
|
||||||
|
1. Static value (for example, `<div class="foo">` or `<div style="color: blue">`)
|
||||||
|
1. Directive host bindings
|
||||||
|
1. Property binding (for example, `host: {'[class.foo]': 'hasFoo'}` or `host: {'[style.color]': 'color'}`)
|
||||||
|
1. Map binding (for example, `host: {'[class]': 'classExpr'}` or `host: {'[style]': 'styleExpr'}`)
|
||||||
|
1. Static value (for example, `host: {'class': 'foo'}` or `host: {'style': 'color: blue'}`)
|
||||||
|
1. Component host bindings
|
||||||
|
1. Property binding (for example, `host: {'[class.foo]': 'hasFoo'}` or `host: {'[style.color]': 'color'}`)
|
||||||
|
1. Map binding (for example, `host: {'[class]': 'classExpr'}` or `host: {'[style]': 'styleExpr'}`)
|
||||||
|
1. Static value (for example, `host: {'class': 'foo'}` or `host: {'style': 'color: blue'}`)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The more specific a class or style binding is, the higher its precedence.
|
||||||
|
|
||||||
|
A binding to a specific class (for example, `[class.foo]`) will take precedence over a generic `[class]` binding, and a binding to a specific style (for example, `[style.bar]`) will take precedence over a generic `[style]` binding.
|
||||||
|
|
||||||
|
<code-example path="attribute-binding/src/app/app.component.html" region="basic-specificity" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Specificity rules also apply when it comes to bindings that originate from different sources.
|
||||||
|
It's possible for an element to have bindings in the template where it's declared, from host bindings on matched directives, and from host bindings on matched components.
|
||||||
|
|
||||||
|
Template bindings are the most specific because they apply to the element directly and exclusively, so they have the highest precedence.
|
||||||
|
|
||||||
|
Directive host bindings are considered less specific because directives can be used in multiple locations, so they have a lower precedence than template bindings.
|
||||||
|
|
||||||
|
Directives often augment component behavior, so host bindings from components have the lowest precedence.
|
||||||
|
|
||||||
|
<code-example path="attribute-binding/src/app/app.component.html" region="source-specificity" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
In addition, bindings take precedence over static attributes.
|
||||||
|
|
||||||
|
In the following case, `class` and `[class]` have similar specificity, but the `[class]` binding will take precedence because it is dynamic.
|
||||||
|
|
||||||
|
<code-example path="attribute-binding/src/app/app.component.html" region="dynamic-priority" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
{@a styling-delegation}
|
||||||
|
### Delegating to styles with lower precedence
|
||||||
|
|
||||||
|
It is possible for higher precedence styles to "delegate" to lower precedence styles using `undefined` values.
|
||||||
|
Whereas setting a style property to `null` ensures the style is removed, setting it to `undefined` will cause Angular to fall back to the next-highest precedence binding to that style.
|
||||||
|
|
||||||
|
For example, consider the following template:
|
||||||
|
|
||||||
|
<code-example path="attribute-binding/src/app/app.component.html" region="style-delegation" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Imagine that the `dirWithHostBinding` directive and the `comp-with-host-binding` component both have a `[style.width]` host binding.
|
||||||
|
In that case, if `dirWithHostBinding` sets its binding to `undefined`, the `width` property will fall back to the value of the `comp-with-host-binding` host binding.
|
||||||
|
However, if `dirWithHostBinding` sets its binding to `null`, the `width` property will be removed entirely.
|
@ -18,12 +18,12 @@ There are three kinds of directives in Angular:
|
|||||||
You saw a component for the first time in the [Getting Started](start "Getting Started with Angular") tutorial.
|
You saw a component for the first time in the [Getting Started](start "Getting Started with Angular") tutorial.
|
||||||
|
|
||||||
*Structural Directives* change the structure of the view.
|
*Structural Directives* change the structure of the view.
|
||||||
Two examples are [NgFor](guide/template-syntax#ngFor) and [NgIf](guide/template-syntax#ngIf).
|
Two examples are [NgFor](guide/built-in-directives#ngFor) and [NgIf](guide/built-in-directives#ngIf).
|
||||||
Learn about them in the [Structural Directives](guide/structural-directives) guide.
|
Learn about them in the [Structural Directives](guide/structural-directives) guide.
|
||||||
|
|
||||||
*Attribute directives* are used as attributes of elements.
|
*Attribute directives* are used as attributes of elements.
|
||||||
The built-in [NgStyle](guide/template-syntax#ngStyle) directive in the
|
The built-in [NgStyle](guide/built-in-directives#ngStyle) directive in the
|
||||||
[Template Syntax](guide/template-syntax) guide, for example,
|
[Built-in directives](guide/built-in-directives) guide, for example,
|
||||||
can change several element styles at the same time.
|
can change several element styles at the same time.
|
||||||
|
|
||||||
## Build a simple attribute directive
|
## Build a simple attribute directive
|
||||||
|
318
aio/content/guide/binding-syntax.md
Normal file
318
aio/content/guide/binding-syntax.md
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
|
||||||
|
# Binding syntax: an overview
|
||||||
|
|
||||||
|
Data-binding is a mechanism for coordinating what users see, specifically
|
||||||
|
with application data values.
|
||||||
|
While you could push values to and pull values from HTML,
|
||||||
|
the application is easier to write, read, and maintain if you turn these tasks over to a binding framework.
|
||||||
|
You simply declare bindings between binding sources, target HTML elements, and let the framework do the rest.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Angular provides many kinds of data-binding. Binding types can be grouped into three categories distinguished by the direction of data flow:
|
||||||
|
|
||||||
|
* From the _source-to-view_
|
||||||
|
* From _view-to-source_
|
||||||
|
* Two-way sequence: _view-to-source-to-view_
|
||||||
|
|
||||||
|
<style>
|
||||||
|
td, th {vertical-align: top}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<col width="30%">
|
||||||
|
</col>
|
||||||
|
<col width="50%">
|
||||||
|
</col>
|
||||||
|
<col width="20%">
|
||||||
|
</col>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Type
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Syntax
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Category
|
||||||
|
</th>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Interpolation<br>
|
||||||
|
Property<br>
|
||||||
|
Attribute<br>
|
||||||
|
Class<br>
|
||||||
|
Style
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<code-example>
|
||||||
|
{{expression}}
|
||||||
|
[target]="expression"
|
||||||
|
bind-target="expression"
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
One-way<br>from data source<br>to view target
|
||||||
|
</td>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Event
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code-example>
|
||||||
|
(target)="statement"
|
||||||
|
on-target="statement"
|
||||||
|
</code-example>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
One-way<br>from view target<br>to data source
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Two-way
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code-example>
|
||||||
|
[(target)]="expression"
|
||||||
|
bindon-target="expression"
|
||||||
|
</code-example>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Two-way
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
Binding types other than interpolation have a **target name** to the left of the equal sign, either surrounded by punctuation, `[]` or `()`,
|
||||||
|
or preceded by a prefix: `bind-`, `on-`, `bindon-`.
|
||||||
|
|
||||||
|
The *target* of a binding is the property or event inside the binding punctuation: `[]`, `()` or `[()]`.
|
||||||
|
|
||||||
|
Every public member of a **source** directive is automatically available for binding.
|
||||||
|
You don't have to do anything special to access a directive member in a template expression or statement.
|
||||||
|
|
||||||
|
|
||||||
|
### Data-binding and HTML
|
||||||
|
|
||||||
|
In the normal course of HTML development, you create a visual structure with HTML elements, and
|
||||||
|
you modify those elements by setting element attributes with string constants.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="special">Plain old HTML</div>
|
||||||
|
<img src="images/item.png">
|
||||||
|
<button disabled>Save</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
With data-binding, you can control things like the state of a button:
|
||||||
|
|
||||||
|
<code-example path="binding-syntax/src/app/app.component.html" region="disabled-button" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Notice that the binding is to the `disabled` property of the button's DOM element,
|
||||||
|
**not** the attribute. This applies to data-binding in general. Data-binding works with *properties* of DOM elements, components, and directives, not HTML *attributes*.
|
||||||
|
|
||||||
|
{@a html-attribute-vs-dom-property}
|
||||||
|
|
||||||
|
### HTML attribute vs. DOM property
|
||||||
|
|
||||||
|
The distinction between an HTML attribute and a DOM property is key to understanding
|
||||||
|
how Angular binding works. **Attributes are defined by HTML. Properties are accessed from DOM (Document Object Model) nodes.**
|
||||||
|
|
||||||
|
* A few HTML attributes have 1:1 mapping to properties; for example, `id`.
|
||||||
|
|
||||||
|
* Some HTML attributes don't have corresponding properties; for example, `aria-*`.
|
||||||
|
|
||||||
|
* Some DOM properties don't have corresponding attributes; for example, `textContent`.
|
||||||
|
|
||||||
|
It is important to remember that *HTML attribute* and the *DOM property* are different things, even when they have the same name.
|
||||||
|
In Angular, the only role of HTML attributes is to initialize element and directive state.
|
||||||
|
|
||||||
|
**Template binding works with *properties* and *events*, not *attributes*.**
|
||||||
|
|
||||||
|
When you write a data-binding, you're dealing exclusively with the *DOM properties* and *events* of the target object.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
This general rule can help you build a mental model of attributes and DOM properties:
|
||||||
|
**Attributes initialize DOM properties and then they are done.
|
||||||
|
Property values can change; attribute values can't.**
|
||||||
|
|
||||||
|
There is one exception to this rule.
|
||||||
|
Attributes can be changed by `setAttribute()`, which re-initializes corresponding DOM properties.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
For more information, see the [MDN Interfaces documentation](https://developer.mozilla.org/en-US/docs/Web/API#Interfaces) which has API docs for all the standard DOM elements and their properties.
|
||||||
|
Comparing the [`<td>` attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/td) attributes to the [`<td>` properties](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement) provides a helpful example for differentiation.
|
||||||
|
In particular, you can navigate from the attributes page to the properties via "DOM interface" link, and navigate the inheritance hierarchy up to `HTMLTableCellElement`.
|
||||||
|
|
||||||
|
|
||||||
|
#### Example 1: an `<input>`
|
||||||
|
|
||||||
|
When the browser renders `<input type="text" value="Sarah">`, it creates a
|
||||||
|
corresponding DOM node with a `value` property initialized to "Sarah".
|
||||||
|
|
||||||
|
```html
|
||||||
|
<input type="text" value="Sarah">
|
||||||
|
```
|
||||||
|
|
||||||
|
When the user enters "Sally" into the `<input>`, the DOM element `value` *property* becomes "Sally".
|
||||||
|
However, if you look at the HTML attribute `value` using `input.getAttribute('value')`, you can see that the *attribute* remains unchanged—it returns "Sarah".
|
||||||
|
|
||||||
|
The HTML attribute `value` specifies the *initial* value; the DOM `value` property is the *current* value.
|
||||||
|
|
||||||
|
To see attributes versus DOM properties in a functioning app, see the <live-example name="binding-syntax"></live-example> especially for binding syntax.
|
||||||
|
|
||||||
|
#### Example 2: a disabled button
|
||||||
|
|
||||||
|
The `disabled` attribute is another example. A button's `disabled`
|
||||||
|
*property* is `false` by default so the button is enabled.
|
||||||
|
|
||||||
|
When you add the `disabled` *attribute*, its presence alone
|
||||||
|
initializes the button's `disabled` *property* to `true`
|
||||||
|
so the button is disabled.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<button disabled>Test Button</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
Adding and removing the `disabled` *attribute* disables and enables the button.
|
||||||
|
However, the value of the *attribute* is irrelevant,
|
||||||
|
which is why you cannot enable a button by writing `<button disabled="false">Still Disabled</button>`.
|
||||||
|
|
||||||
|
To control the state of the button, set the `disabled` *property*,
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Though you could technically set the `[attr.disabled]` attribute binding, the values are different in that the property binding requires to a boolean value, while its corresponding attribute binding relies on whether the value is `null` or not. Consider the following:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<input [disabled]="condition ? true : false">
|
||||||
|
<input [attr.disabled]="condition ? 'disabled' : null">
|
||||||
|
```
|
||||||
|
|
||||||
|
Generally, use property binding over attribute binding as it is more intuitive (being a boolean value), has a shorter syntax, and is more performant.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
To see the `disabled` button example in a functioning app, see the <live-example name="binding-syntax"></live-example> especially for binding syntax. This example shows you how to toggle the disabled property from the component.
|
||||||
|
|
||||||
|
## Binding types and targets
|
||||||
|
|
||||||
|
The **target of a data-binding** is something in the DOM.
|
||||||
|
Depending on the binding type, the target can be a property (element, component, or directive),
|
||||||
|
an event (element, component, or directive), or sometimes an attribute name.
|
||||||
|
The following table summarizes the targets for the different binding types.
|
||||||
|
|
||||||
|
<style>
|
||||||
|
td, th {vertical-align: top}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<table width="100%">
|
||||||
|
<col width="10%">
|
||||||
|
</col>
|
||||||
|
<col width="15%">
|
||||||
|
</col>
|
||||||
|
<col width="75%">
|
||||||
|
</col>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Type
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Target
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Examples
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Property
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Element property<br>
|
||||||
|
Component property<br>
|
||||||
|
Directive property
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code>src</code>, <code>hero</code>, and <code>ngClass</code> in the following:
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="property-binding-syntax-1"></code-example>
|
||||||
|
<!-- For more information, see [Property Binding](guide/property-binding). -->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Event
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Element event<br>
|
||||||
|
Component event<br>
|
||||||
|
Directive event
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code>click</code>, <code>deleteRequest</code>, and <code>myClick</code> in the following:
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="event-binding-syntax-1"></code-example>
|
||||||
|
<!-- KW--Why don't these links work in the table? -->
|
||||||
|
<!-- <div>For more information, see [Event Binding](guide/event-binding).</div> -->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Two-way
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Event and property
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="2-way-binding-syntax-1"></code-example>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Attribute
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
Attribute
|
||||||
|
(the exception)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="attribute-binding-syntax-1"></code-example>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Class
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code>class</code> property
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="class-binding-syntax-1"></code-example>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Style
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code>style</code> property
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="style-binding-syntax-1"></code-example>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
@ -526,7 +526,7 @@ For example:
|
|||||||
// __Zone_enable_cross_context_check = true;
|
// __Zone_enable_cross_context_check = true;
|
||||||
</script>
|
</script>
|
||||||
<!-- zone.js required by Angular -->
|
<!-- zone.js required by Angular -->
|
||||||
<script src="node_modules/zone.js/bundles/zone.umd.js"></script>
|
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||||
|
|
||||||
<!-- application polyfills -->
|
<!-- application polyfills -->
|
||||||
</code-example>
|
</code-example>
|
||||||
|
435
aio/content/guide/built-in-directives.md
Normal file
435
aio/content/guide/built-in-directives.md
Normal file
@ -0,0 +1,435 @@
|
|||||||
|
# Built-in directives
|
||||||
|
|
||||||
|
Angular offers two kinds of built-in directives: [_attribute_ directives](guide/attribute-directives) and [_structural_ directives](guide/structural-directives).
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
For more detail, including how to build your own custom directives, see [Attribute Directives](guide/attribute-directives) and [Structural Directives](guide/structural-directives).
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a attribute-directives}
|
||||||
|
|
||||||
|
## Built-in attribute directives
|
||||||
|
|
||||||
|
Attribute directives listen to and modify the behavior of
|
||||||
|
other HTML elements, attributes, properties, and components.
|
||||||
|
You usually apply them to elements as if they were HTML attributes, hence the name.
|
||||||
|
|
||||||
|
Many NgModules such as the [`RouterModule`](guide/router "Routing and Navigation")
|
||||||
|
and the [`FormsModule`](guide/forms "Forms") define their own attribute directives.
|
||||||
|
The most common attribute directives are as follows:
|
||||||
|
|
||||||
|
* [`NgClass`](guide/built-in-directives#ngClass)—adds and removes a set of CSS classes.
|
||||||
|
* [`NgStyle`](guide/built-in-directives#ngStyle)—adds and removes a set of HTML styles.
|
||||||
|
* [`NgModel`](guide/built-in-directives#ngModel)—adds two-way data binding to an HTML form element.
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a ngClass}
|
||||||
|
|
||||||
|
## `NgClass`
|
||||||
|
|
||||||
|
Add or remove several CSS classes simultaneously with `ngClass`.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="special-div" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
To add or remove a *single* class, use [class binding](guide/attribute-binding#class-binding) rather than `NgClass`.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Consider a `setCurrentClasses()` component method that sets a component property,
|
||||||
|
`currentClasses`, with an object that adds or removes three classes based on the
|
||||||
|
`true`/`false` state of three other component properties. Each key of the object is a CSS class name; its value is `true` if the class should be added,
|
||||||
|
`false` if it should be removed.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.ts" region="setClasses" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
Adding an `ngClass` property binding to `currentClasses` sets the element's classes accordingly:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgClass-1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Remember that in this situation you'd call `setCurrentClasses()`,
|
||||||
|
both initially and when the dependent properties change.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a ngStyle}
|
||||||
|
|
||||||
|
## `NgStyle`
|
||||||
|
|
||||||
|
Use `NgStyle` to set many inline styles simultaneously and dynamically, based on the state of the component.
|
||||||
|
|
||||||
|
### Without `NgStyle`
|
||||||
|
|
||||||
|
For context, consider setting a *single* style value with [style binding](guide/attribute-binding#style-binding), without `NgStyle`.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="without-ng-style" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
However, to set *many* inline styles at the same time, use the `NgStyle` directive.
|
||||||
|
|
||||||
|
The following is a `setCurrentStyles()` method that sets a component
|
||||||
|
property, `currentStyles`, with an object that defines three styles,
|
||||||
|
based on the state of three other component properties:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.ts" region="setStyles" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
Adding an `ngStyle` property binding to `currentStyles` sets the element's styles accordingly:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgStyle-2" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Remember to call `setCurrentStyles()`, both initially and when the dependent properties change.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a ngModel}
|
||||||
|
|
||||||
|
## `[(ngModel)]`: Two-way binding
|
||||||
|
|
||||||
|
The `NgModel` directive allows you to display a data property and
|
||||||
|
update that property when the user makes changes. Here's an example:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" header="src/app/app.component.html (NgModel example)" region="NgModel-1"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
### Import `FormsModule` to use `ngModel`
|
||||||
|
|
||||||
|
Before using the `ngModel` directive in a two-way data binding,
|
||||||
|
you must import the `FormsModule` and add it to the NgModule's `imports` list.
|
||||||
|
Learn more about the `FormsModule` and `ngModel` in [Forms](guide/forms#ngModel).
|
||||||
|
|
||||||
|
Remember to import the `FormsModule` to make `[(ngModel)]` available as follows:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.module.ts" header="src/app/app.module.ts (FormsModule import)" region="import-forms-module"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
You could achieve the same result with separate bindings to
|
||||||
|
the `<input>` element's `value` property and `input` event:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="without-NgModel" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
To streamline the syntax, the `ngModel` directive hides the details behind its own `ngModel` input and `ngModelChange` output properties:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgModelChange" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The `ngModel` data property sets the element's value property and the `ngModelChange` event property
|
||||||
|
listens for changes to the element's value.
|
||||||
|
|
||||||
|
### `NgModel` and value accessors
|
||||||
|
|
||||||
|
The details are specific to each kind of element and therefore the `NgModel` directive only works for an element
|
||||||
|
supported by a [ControlValueAccessor](api/forms/ControlValueAccessor)
|
||||||
|
that adapts an element to this protocol.
|
||||||
|
Angular provides *value accessors* for all of the basic HTML form elements and the
|
||||||
|
[Forms](guide/forms) guide shows how to bind to them.
|
||||||
|
|
||||||
|
You can't apply `[(ngModel)]` to a non-form native element or a
|
||||||
|
third-party custom component until you write a suitable value accessor. For more information, see
|
||||||
|
the API documentation on [DefaultValueAccessor](https://angular.io/api/forms/DefaultValueAccessor).
|
||||||
|
|
||||||
|
You don't need a value accessor for an Angular component that
|
||||||
|
you write because you can name the value and event properties
|
||||||
|
to suit Angular's basic [two-way binding syntax](guide/two-way-binding)
|
||||||
|
and skip `NgModel` altogether.
|
||||||
|
The `sizer` in the
|
||||||
|
[Two-way Binding](guide/two-way-binding) section is an example of this technique.
|
||||||
|
|
||||||
|
Separate `ngModel` bindings are an improvement over binding to the
|
||||||
|
element's native properties, but you can streamline the binding with a
|
||||||
|
single declaration using the `[(ngModel)]` syntax:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgModel-1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
This `[(ngModel)]` syntax can only _set_ a data-bound property.
|
||||||
|
If you need to do something more, you can write the expanded form;
|
||||||
|
for example, the following changes the `<input>` value to uppercase:
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="uppercase" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Here are all variations in action, including the uppercase version:
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src='generated/images/guide/built-in-directives/ng-model-anim.gif' alt="NgModel variations">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a structural-directives}
|
||||||
|
|
||||||
|
## Built-in _structural_ directives
|
||||||
|
|
||||||
|
Structural directives are responsible for HTML layout.
|
||||||
|
They shape or reshape the DOM's structure, typically by adding, removing, and manipulating
|
||||||
|
the host elements to which they are attached.
|
||||||
|
|
||||||
|
This section is an introduction to the common built-in structural directives:
|
||||||
|
|
||||||
|
* [`NgIf`](guide/built-in-directives#ngIf)—conditionally creates or destroys subviews from the template.
|
||||||
|
* [`NgFor`](guide/built-in-directives#ngFor)—repeat a node for each item in a list.
|
||||||
|
* [`NgSwitch`](guide/built-in-directives#ngSwitch)—a set of directives that switch among alternative views.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
The deep details of structural directives are covered in the
|
||||||
|
[Structural Directives](guide/structural-directives) guide,
|
||||||
|
which explains the following:
|
||||||
|
|
||||||
|
* Why you
|
||||||
|
[prefix the directive name with an asterisk (\*)](guide/structural-directives#the-asterisk--prefix).
|
||||||
|
* Using [`<ng-container>`](guide/structural-directives#ngcontainer "<ng-container>")
|
||||||
|
to group elements when there is no suitable host element for the directive.
|
||||||
|
* How to write your own structural directive.
|
||||||
|
* That you can only apply [one structural directive](guide/structural-directives#one-per-element "one per host element") to an element.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a ngIf}
|
||||||
|
|
||||||
|
## NgIf
|
||||||
|
|
||||||
|
You can add or remove an element from the DOM by applying an `NgIf` directive to
|
||||||
|
a host element.
|
||||||
|
Bind the directive to a condition expression like `isActive` in this example.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgIf-1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Don't forget the asterisk (`*`) in front of `ngIf`. For more information
|
||||||
|
on the asterisk, see the [asterisk (*) prefix](guide/structural-directives#the-asterisk--prefix) section of
|
||||||
|
[Structural Directives](guide/structural-directives).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
When the `isActive` expression returns a truthy value, `NgIf` adds the
|
||||||
|
`ItemDetailComponent` to the DOM.
|
||||||
|
When the expression is falsy, `NgIf` removes the `ItemDetailComponent`
|
||||||
|
from the DOM, destroying that component and all of its sub-components.
|
||||||
|
|
||||||
|
|
||||||
|
### Show/hide vs. `NgIf`
|
||||||
|
|
||||||
|
Hiding an element is different from removing it with `NgIf`.
|
||||||
|
For comparison, the following example shows how to control
|
||||||
|
the visibility of an element with a
|
||||||
|
[class](guide/attribute-binding#class-binding) or [style](guide/attribute-binding#style-binding) binding.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgIf-3" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
When you hide an element, that element and all of its descendants remain in the DOM.
|
||||||
|
All components for those elements stay in memory and
|
||||||
|
Angular may continue to check for changes.
|
||||||
|
You could be holding onto considerable computing resources and degrading performance
|
||||||
|
unnecessarily.
|
||||||
|
|
||||||
|
`NgIf` works differently. When `NgIf` is `false`, Angular removes the element and its descendants from the DOM.
|
||||||
|
It destroys their components, freeing up resources, which
|
||||||
|
results in a better user experience.
|
||||||
|
|
||||||
|
If you are hiding large component trees, consider `NgIf` as a more
|
||||||
|
efficient alternative to showing/hiding.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
For more information on `NgIf` and `ngIfElse`, see the [API documentation about NgIf](api/common/NgIf).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
### Guard against null
|
||||||
|
|
||||||
|
Another advantage of `ngIf` is that you can use it to guard against null. Show/hide
|
||||||
|
is best suited for very simple use cases, so when you need a guard, opt instead for `ngIf`. Angular will throw an error if a nested expression tries to access a property of `null`.
|
||||||
|
|
||||||
|
The following shows `NgIf` guarding two `<div>`s.
|
||||||
|
The `currentCustomer` name appears only when there is a `currentCustomer`.
|
||||||
|
The `nullCustomer` will not be displayed as long as it is `null`.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgIf-2" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgIf-2b" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See also the
|
||||||
|
[safe navigation operator](guide/template-expression-operators#safe-navigation-operator "Safe navigation operator (?.)") below.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a ngFor}
|
||||||
|
## `NgFor`
|
||||||
|
|
||||||
|
`NgFor` is a repeater directive—a way to present a list of items.
|
||||||
|
You define a block of HTML that defines how a single item should be displayed
|
||||||
|
and then you tell Angular to use that block as a template for rendering each item in the list.
|
||||||
|
The text assigned to `*ngFor` is the instruction that guides the repeater process.
|
||||||
|
|
||||||
|
The following example shows `NgFor` applied to a simple `<div>`. (Don't forget the asterisk (`*`) in front of `ngFor`.)
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgFor-1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Don't forget the asterisk (`*`) in front of `ngFor`. For more information
|
||||||
|
on the asterisk, see the [asterisk (*) prefix](guide/structural-directives#the-asterisk--prefix) section of
|
||||||
|
[Structural Directives](guide/structural-directives).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
You can also apply an `NgFor` to a component element, as in the following example.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgFor-2" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
{@a microsyntax}
|
||||||
|
|
||||||
|
<div class="callout is-critical">
|
||||||
|
<header>*ngFor microsyntax</header>
|
||||||
|
|
||||||
|
The string assigned to `*ngFor` is not a [template expression](guide/interpolation). Rather,
|
||||||
|
it's a *microsyntax*—a little language of its own that Angular interprets.
|
||||||
|
The string `"let item of items"` means:
|
||||||
|
|
||||||
|
> *Take each item in the `items` array, store it in the local `item` looping variable, and
|
||||||
|
make it available to the templated HTML for each iteration.*
|
||||||
|
|
||||||
|
Angular translates this instruction into an `<ng-template>` around the host element,
|
||||||
|
then uses this template repeatedly to create a new set of elements and bindings for each `item`
|
||||||
|
in the list.
|
||||||
|
For more information about microsyntax, see the [Structural Directives](guide/structural-directives#microsyntax) guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{@a template-input-variable}
|
||||||
|
|
||||||
|
{@a template-input-variables}
|
||||||
|
|
||||||
|
### Template input variables
|
||||||
|
|
||||||
|
The `let` keyword before `item` creates a template input variable called `item`.
|
||||||
|
The `ngFor` directive iterates over the `items` array returned by the parent component's `items` property
|
||||||
|
and sets `item` to the current item from the array during each iteration.
|
||||||
|
|
||||||
|
Reference `item` within the `ngFor` host element
|
||||||
|
as well as within its descendants to access the item's properties.
|
||||||
|
The following example references `item` first in an interpolation
|
||||||
|
and then passes in a binding to the `item` property of the `<app-item-detail>` component.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgFor-1-2" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
For more information about template input variables, see
|
||||||
|
[Structural Directives](guide/structural-directives#template-input-variable).
|
||||||
|
|
||||||
|
### `*ngFor` with `index`
|
||||||
|
|
||||||
|
The `index` property of the `NgFor` directive context
|
||||||
|
returns the zero-based index of the item in each iteration.
|
||||||
|
You can capture the `index` in a template input variable and use it in the template.
|
||||||
|
|
||||||
|
The next example captures the `index` in a variable named `i` and displays it with the item name.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgFor-3" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
`NgFor` is implemented by the `NgForOf` directive. Read more about the other `NgForOf` context values such as `last`, `even`,
|
||||||
|
and `odd` in the [NgForOf API reference](api/common/NgForOf).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a trackBy}
|
||||||
|
### *ngFor with `trackBy`
|
||||||
|
|
||||||
|
If you use `NgFor` with large lists, a small change to one item, such as removing or adding an item, can trigger a cascade of DOM manipulations. For example, re-querying the server could reset a list with all new item objects, even when those items were previously displayed. In this case, Angular sees only a fresh list of new object references and has no choice but to replace the old DOM elements with all new DOM elements.
|
||||||
|
|
||||||
|
You can make this more efficient with `trackBy`.
|
||||||
|
Add a method to the component that returns the value `NgFor` should track.
|
||||||
|
In this case, that value is the hero's `id`. If the `id` has already been rendered,
|
||||||
|
Angular keeps track of it and doesn't re-query the server for the same `id`.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.ts" region="trackByItems" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
In the microsyntax expression, set `trackBy` to the `trackByItems()` method.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="trackBy" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Here is an illustration of the `trackBy` effect.
|
||||||
|
"Reset items" creates new items with the same `item.id`s.
|
||||||
|
"Change ids" creates new items with new `item.id`s.
|
||||||
|
|
||||||
|
* With no `trackBy`, both buttons trigger complete DOM element replacement.
|
||||||
|
* With `trackBy`, only changing the `id` triggers element replacement.
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src="generated/images/guide/built-in-directives/ngfor-trackby.gif" alt="Animation of trackBy">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Built-in directives use only public APIs; that is,
|
||||||
|
they do not have special access to any private APIs that other directives can't access.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a ngSwitch}
|
||||||
|
## The `NgSwitch` directives
|
||||||
|
|
||||||
|
NgSwitch is like the JavaScript `switch` statement.
|
||||||
|
It displays one element from among several possible elements, based on a switch condition.
|
||||||
|
Angular puts only the selected element into the DOM.
|
||||||
|
<!-- API Flagged -->
|
||||||
|
`NgSwitch` is actually a set of three, cooperating directives:
|
||||||
|
`NgSwitch`, `NgSwitchCase`, and `NgSwitchDefault` as in the following example.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgSwitch" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src="generated/images/guide/built-in-directives/ngswitch.gif" alt="Animation of NgSwitch">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`NgSwitch` is the controller directive. Bind it to an expression that returns
|
||||||
|
the *switch value*, such as `feature`. Though the `feature` value in this
|
||||||
|
example is a string, the switch value can be of any type.
|
||||||
|
|
||||||
|
**Bind to `[ngSwitch]`**. You'll get an error if you try to set `*ngSwitch` because
|
||||||
|
`NgSwitch` is an *attribute* directive, not a *structural* directive.
|
||||||
|
Rather than touching the DOM directly, it changes the behavior of its companion directives.
|
||||||
|
|
||||||
|
**Bind to `*ngSwitchCase` and `*ngSwitchDefault`**.
|
||||||
|
The `NgSwitchCase` and `NgSwitchDefault` directives are _structural_ directives
|
||||||
|
because they add or remove elements from the DOM.
|
||||||
|
|
||||||
|
* `NgSwitchCase` adds its element to the DOM when its bound value equals the switch value and removes
|
||||||
|
its bound value when it doesn't equal the switch value.
|
||||||
|
|
||||||
|
* `NgSwitchDefault` adds its element to the DOM when there is no selected `NgSwitchCase`.
|
||||||
|
|
||||||
|
The switch directives are particularly useful for adding and removing *component elements*.
|
||||||
|
This example switches among four `item` components defined in the `item-switch.components.ts` file.
|
||||||
|
Each component has an `item` [input property](guide/inputs-outputs#input "Input property")
|
||||||
|
which is bound to the `currentItem` of the parent component.
|
||||||
|
|
||||||
|
Switch directives work as well with native elements and web components too.
|
||||||
|
For example, you could replace the `<app-best-item>` switch case with the following.
|
||||||
|
|
||||||
|
<code-example path="built-in-directives/src/app/app.component.html" region="NgSwitch-div" header="src/app/app.component.html"></code-example>
|
@ -25,7 +25,7 @@ in which two or more components share information.
|
|||||||
## Pass data from parent to child with input binding
|
## Pass data from parent to child with input binding
|
||||||
|
|
||||||
`HeroChildComponent` has two ***input properties***,
|
`HeroChildComponent` has two ***input properties***,
|
||||||
typically adorned with [@Input decorations](guide/template-syntax#inputs-outputs).
|
typically adorned with [@Input() decorator](guide/inputs-outputs#input).
|
||||||
|
|
||||||
|
|
||||||
<code-example path="component-interaction/src/app/hero-child.component.ts" header="component-interaction/src/app/hero-child.component.ts">
|
<code-example path="component-interaction/src/app/hero-child.component.ts" header="component-interaction/src/app/hero-child.component.ts">
|
||||||
@ -180,7 +180,7 @@ The child component exposes an `EventEmitter` property with which it `emits` eve
|
|||||||
The parent binds to that event property and reacts to those events.
|
The parent binds to that event property and reacts to those events.
|
||||||
|
|
||||||
The child's `EventEmitter` property is an ***output property***,
|
The child's `EventEmitter` property is an ***output property***,
|
||||||
typically adorned with an [@Output decoration](guide/template-syntax#inputs-outputs)
|
typically adorned with an [@Output() decorator](guide/inputs-outputs#output)
|
||||||
as seen in this `VoterComponent`:
|
as seen in this `VoterComponent`:
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
# Creating libraries
|
# Creating libraries
|
||||||
|
|
||||||
This page provides a conceptual overview of how you can create and publish new libraries to extend Angular functionality.
|
You can create and publish new libraries to extend Angular functionality. If you find that you need to solve the same problem in more than one app (or want to share your solution with other developers), you have a candidate for a library.
|
||||||
|
|
||||||
If you find that you need to solve the same problem in more than one app (or want to share your solution with other developers), you have a candidate for a library.
|
|
||||||
A simple example might be a button that sends users to your company website, that would be included in all apps that your company builds.
|
A simple example might be a button that sends users to your company website, that would be included in all apps that your company builds.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
<p>For more details on how a library project is structured you can refer the <a href="guide/file-structure#library-project-files">Library Project Files</a></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
Use the Angular CLI to generate a new library skeleton in a new workspace with the following commands.
|
Use the Angular CLI to generate a new library skeleton with the following command:
|
||||||
|
|
||||||
<code-example language="bash">
|
<code-example language="bash">
|
||||||
ng new my-workspace --create-application=false
|
ng new my-workspace --create-application=false
|
||||||
@ -15,18 +18,12 @@ Use the Angular CLI to generate a new library skeleton in a new workspace with t
|
|||||||
ng generate library my-lib
|
ng generate library my-lib
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
The `ng generate` command creates the `projects/my-lib` folder in your workspace, which contains a component and a service inside an NgModule.
|
|
||||||
|
|
||||||
<div class="alert is-helpful">
|
<div class="alert is-helpful">
|
||||||
|
<p>You can use the monorepo model to use the same workspace for multiple projects. See <a href="guide/file-structure#multiple-projects">Setting up for a multi-project workspace</a>.</p>
|
||||||
For more details on how a library project is structured, refer to the [Library project files](guide/file-structure#library-project-files) section of the [Project File Structure guide](guide/file-structure).
|
|
||||||
|
|
||||||
You can use the monorepo model to use the same workspace for multiple projects.
|
|
||||||
See [Setting up for a multi-project workspace](guide/file-structure#multiple-projects).
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
When you generate a new library, the workspace configuration file, `angular.json`, is updated with a project of type 'library'.
|
This creates the `projects/my-lib` folder in your workspace, which contains a component and a service inside an NgModule.
|
||||||
|
The workspace configuration file, `angular.json`, is updated with a project of type 'library'.
|
||||||
|
|
||||||
<code-example format="json">
|
<code-example format="json">
|
||||||
"projects": {
|
"projects": {
|
||||||
@ -72,30 +69,35 @@ Here are some things to consider in migrating application functionality to a lib
|
|||||||
|
|
||||||
* Components should expose their interactions through inputs for providing context, and outputs for communicating events to other components.
|
* Components should expose their interactions through inputs for providing context, and outputs for communicating events to other components.
|
||||||
|
|
||||||
|
* Services should declare their own providers (rather than declaring providers in the NgModule or a component), so that they are *tree-shakable*. This allows the compiler to leave the service out of the bundle if it never gets injected into the application that imports the library. For more about this, see [Tree-shakable providers](guide/dependency-injection-providers#tree-shakable-providers).
|
||||||
|
|
||||||
|
* If you register global service providers or share providers across multiple NgModules, use the [`forRoot()` and `forChild()` patterns](guide/singleton-services) provided by the [RouterModule](api/router/RouterModule).
|
||||||
|
|
||||||
* Check all internal dependencies.
|
* Check all internal dependencies.
|
||||||
* For custom classes or interfaces used in components or service, check whether they depend on additional classes or interfaces that also need to be migrated.
|
* For custom classes or interfaces used in components or service, check whether they depend on additional classes or interfaces that also need to be migrated.
|
||||||
* Similarly, if your library code depends on a service, that service needs to be migrated.
|
* Similarly, if your library code depends on a service, that service needs to be migrated.
|
||||||
* If your library code or its templates depend on other libraries (such as Angular Material, for instance), you must configure your library with those dependencies.
|
* If your library code or its templates depend on other libraries (such a Angular Material, for instance), you must configure your library with those dependencies.
|
||||||
|
|
||||||
* Consider how you provide services to client applications.
|
## Reusable code and schematics
|
||||||
|
|
||||||
* Services should declare their own providers (rather than declaring providers in the NgModule or a component), so that they are *tree-shakable*. This allows the compiler to leave the service out of the bundle if it never gets injected into the application that imports the library. For more about this, see [Tree-shakable providers](guide/dependency-injection-providers#tree-shakable-providers).
|
A library typically includes *reusable code* that defines components, services, and other Angular artifacts (pipes, directives, and so on) that you simply import into a project.
|
||||||
|
A library is packaged into an npm package for publishing and sharing, and this package can also include [schematics](guide/glossary#schematic) that provide instructions for generating or transforming code directly in your project, in the same way that the CLI creates a generic skeleton app with `ng generate component`.
|
||||||
|
A schematic that is combined with a library can, for example, provide the Angular CLI with the information it needs to generate a particular component defined in that library.
|
||||||
|
|
||||||
* If you register global service providers or share providers across multiple NgModules, use the [`forRoot()` and `forChild()` design patterns](guide/singleton-services) provided by the [RouterModule](api/router/RouterModule).
|
What you include in your library is determined by the kind of task you are trying to accomplish.
|
||||||
|
For example, if you want a dropdown with some canned data to show how to add it to your app, your library could define a schematic to create it.
|
||||||
|
For a component like a dropdown that would contain different passed-in values each time, you could provide it as a component in a shared library.
|
||||||
|
|
||||||
* If your library provides optional services that might not be used by all client applications, support proper tree-shaking for that case by using the [lightweight token design pattern](guide/lightweight-injection-tokens).
|
Suppose you want to read a configuration file and then generate a form based on that configuration.
|
||||||
|
If that form will need additional customization by the user, it might work best as a schematic.
|
||||||
|
However, if the forms will always be the same and not need much customization by developers, then you could create a dynamic component that takes the configuration and generates the form.
|
||||||
|
In general, the more complex the customization, the more useful the schematic approach.
|
||||||
|
|
||||||
{@a integrating-with-the-cli}
|
{@a integrating-with-the-cli}
|
||||||
|
|
||||||
## Integrating with the CLI using code-generation schematics
|
## Integrating with the CLI
|
||||||
|
|
||||||
A library typically includes *reusable code* that defines components, services, and other Angular artifacts (pipes, directives, and so on) that you simply import into a project.
|
A library can include [schematics](guide/glossary#schematic) that allow it to integrate with the Angular CLI.
|
||||||
A library is packaged into an npm package for publishing and sharing.
|
|
||||||
This package can also include [schematics](guide/glossary#schematic) that provide instructions for generating or transforming code directly in your project, in the same way that the CLI creates a generic new component with `ng generate component`.
|
|
||||||
A schematic that is packaged with a library can, for example, provide the Angular CLI with the information it needs to generate a component that configures and uses a particular feature, or set of features, defined in that library.
|
|
||||||
One example of this is Angular Material's navigation schematic which configures the CDK's `BreakpointObserver` and uses it with Material's `MatSideNav` and `MatToolbar` components.
|
|
||||||
|
|
||||||
You can create and include the following kinds of schematics.
|
|
||||||
|
|
||||||
* Include an installation schematic so that `ng add` can add your library to a project.
|
* Include an installation schematic so that `ng add` can add your library to a project.
|
||||||
|
|
||||||
@ -103,15 +105,6 @@ You can create and include the following kinds of schematics.
|
|||||||
|
|
||||||
* Include an update schematic so that `ng update` can update your library’s dependencies and provide migrations for breaking changes in new releases.
|
* Include an update schematic so that `ng update` can update your library’s dependencies and provide migrations for breaking changes in new releases.
|
||||||
|
|
||||||
What you include in your library depends on your task.
|
|
||||||
For example, you could define a schematic to create a dropdown that is pre-populated with canned data to show how to add it to an app.
|
|
||||||
If you want a dropdown that would contain different passed-in values each time, your library could define a schematic to create it with a given configuration. Developers could then use `ng generate` to configure an instance for their own app.
|
|
||||||
|
|
||||||
Suppose you want to read a configuration file and then generate a form based on that configuration.
|
|
||||||
If that form will need additional customization by the developer who is using your library, it might work best as a schematic.
|
|
||||||
However, if the forms will always be the same and not need much customization by developers, then you could create a dynamic component that takes the configuration and generates the form.
|
|
||||||
In general, the more complex the customization, the more useful the schematic approach.
|
|
||||||
|
|
||||||
To learn more, see [Schematics Overview](guide/schematics) and [Schematics for Libraries](guide/schematics-for-libraries).
|
To learn more, see [Schematics Overview](guide/schematics) and [Schematics for Libraries](guide/schematics-for-libraries).
|
||||||
|
|
||||||
## Publishing your library
|
## Publishing your library
|
||||||
@ -132,7 +125,7 @@ If you've never published a package in npm before, you must create a user accoun
|
|||||||
|
|
||||||
For now, it is not recommended to publish Ivy libraries to NPM because Ivy generated code is not backward compatible with View Engine, so apps using View Engine will not be able to consume them. Furthermore, the internal Ivy instructions are not yet stable, which can potentially break consumers using a different Angular version from the one used to build the library.
|
For now, it is not recommended to publish Ivy libraries to NPM because Ivy generated code is not backward compatible with View Engine, so apps using View Engine will not be able to consume them. Furthermore, the internal Ivy instructions are not yet stable, which can potentially break consumers using a different Angular version from the one used to build the library.
|
||||||
|
|
||||||
When a published library is used in an Ivy app, the Angular CLI will automatically convert it to Ivy using a tool known as the Angular compatibility compiler (`ngcc`). Thus, by publishing your libraries using the View Engine compiler ensures that they can be transparently consumed by both View Engine and Ivy apps.
|
When a published library is used in an Ivy app, the Angular CLI will automatically convert it to Ivy using a tool known as the Angular compatibility compiler (`ngcc`). Thus, publishing your libraries using the View Engine compiler ensures that they can be transparently consumed by both View Engine and Ivy apps.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -284,6 +284,23 @@ Search for [Constants in API documentation](api?type=const) to find more built-i
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Note that the reference to the array returned for a `multi` provider is shared between all the
|
||||||
|
places where the token is injected. We recommend avoiding mutations of the array (especially for
|
||||||
|
predefined tokens) as it may lead to unexpected behavior in other parts of the app that inject
|
||||||
|
the same token. You can prevent the value from being mutated by setting its type to `ReadonlyArray`.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
You can use `ReadonlyArray` to type your `multi` provider, so TypeScript triggers an error in case
|
||||||
|
of unwanted array mutations:
|
||||||
|
|
||||||
|
```
|
||||||
|
constructor(@Inject(MULTI_PROVIDER) multiProvider: ReadonlyArray<MultiProvider>) {
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
{@a tree-shakable-provider}
|
{@a tree-shakable-provider}
|
||||||
{@a tree-shakable-providers}
|
{@a tree-shakable-providers}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ them on demand.
|
|||||||
|
|
||||||
<header>Don't eagerly import something from a lazy-loaded module</header>
|
<header>Don't eagerly import something from a lazy-loaded module</header>
|
||||||
|
|
||||||
If you mean to lazy-load a module, be careful not import it
|
If you mean to lazy-load a module, be careful not to import it
|
||||||
in a file that's eagerly loaded when the app starts (such as the root `AppModule`).
|
in a file that's eagerly loaded when the app starts (such as the root `AppModule`).
|
||||||
If you do that, the module will be loaded immediately.
|
If you do that, the module will be loaded immediately.
|
||||||
|
|
||||||
@ -448,13 +448,13 @@ When targeting older browsers, [polyfills](guide/browser-support#polyfills) can
|
|||||||
|
|
||||||
To maximize compatibility, you could ship a single bundle that includes all your compiled code, plus any polyfills that may be needed.
|
To maximize compatibility, you could ship a single bundle that includes all your compiled code, plus any polyfills that may be needed.
|
||||||
Users with modern browsers, however, shouldn't have to pay the price of increased bundle size that comes with polyfills they don't need.
|
Users with modern browsers, however, shouldn't have to pay the price of increased bundle size that comes with polyfills they don't need.
|
||||||
Differential loading, which is supported in Angular CLI version 8 and higher, can help solve this problem.
|
Differential loading, which is supported by default in Angular CLI version 8 and higher, solves this problem.
|
||||||
|
|
||||||
Differential loading is a strategy that allows your web application to support multiple browsers, but only load the necessary code that the browser needs. When differential loading is enabled the CLI builds two separate bundles as part of your deployed application.
|
Differential loading is a strategy that allows your web application to support multiple browsers, but only load the necessary code that the browser needs. When differential loading is enabled (which is the default) the CLI builds two separate bundles as part of your deployed application.
|
||||||
|
|
||||||
* The first bundle contains modern ES2015 syntax. This bundle takes advantage of built-in support in modern browsers, ships fewer polyfills, and results in a smaller bundle size.
|
* The first bundle contains modern ES2015 syntax, takes advantage of built-in support in modern browsers, ships fewer polyfills, and results in a smaller bundle size.
|
||||||
|
|
||||||
* The second bundle contains code in the old ES5 syntax, along with all necessary polyfills. This second bundle is larger, but supports older browsers.
|
* The second bundle contains code in the old ES5 syntax, along with all necessary polyfills. This results in a larger bundle size, but supports older browsers.
|
||||||
|
|
||||||
### Differential builds
|
### Differential builds
|
||||||
|
|
||||||
@ -465,7 +465,7 @@ The following configurations determine your requirements.
|
|||||||
|
|
||||||
* Browsers list
|
* Browsers list
|
||||||
|
|
||||||
The Browserslist configuration file is included in your application [project structure](guide/file-structure#application-configuration-files) and provides the minimum browsers your application supports. See the [Browserslist spec](https://github.com/browserslist/browserslist) for complete configuration options.
|
The `browserslist` configuration file is included in your application [project structure](guide/file-structure#application-configuration-files) and provides the minimum browsers your application supports. See the [Browserslist spec](https://github.com/browserslist/browserslist) for complete configuration options.
|
||||||
|
|
||||||
* TypeScript configuration
|
* TypeScript configuration
|
||||||
|
|
||||||
@ -509,27 +509,16 @@ Each script tag has a `type="module"` or `nomodule` attribute. Browsers with nat
|
|||||||
|
|
||||||
### Configuring differential loading
|
### Configuring differential loading
|
||||||
|
|
||||||
To include differential loading in your application builds, you must configure the Browserslist and TypeScript configuration files in your application project.
|
Differential loading is supported by default with version 8 and later of the Angular CLI.
|
||||||
|
For each application project in your workspace, you can configure how builds are produced based on the `browserslist` and `tsconfig.json` configuration files in your application project.
|
||||||
|
|
||||||
The following examples show a `browserlistrc` and `tsconfig.json` file for a newly created Angular application. In this configuration, legacy browsers such as IE 9-11 are ignored, and the compilation target is ES2015.
|
For a newly created Angular application, legacy browsers such as IE 9-11 are ignored, and the compilation target is ES2015.
|
||||||
|
|
||||||
<code-example language="none" header="browserslistrc">
|
<code-example language="none" header="browserslist">
|
||||||
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
|
> 0.5%
|
||||||
# For additional information regarding the format and rule options, please see:
|
last 2 versions
|
||||||
# https://github.com/browserslist/browserslist#queries
|
|
||||||
|
|
||||||
# For the full list of supported browsers by the Angular framework, please see:
|
|
||||||
# https://angular.io/guide/browser-support
|
|
||||||
|
|
||||||
# You can see what browsers were selected by your queries by running:
|
|
||||||
# npx browserslist
|
|
||||||
|
|
||||||
last 1 Chrome version
|
|
||||||
last 1 Firefox version
|
|
||||||
last 2 Edge major versions
|
|
||||||
last 2 Safari major version
|
|
||||||
last 2 iOS major versions
|
|
||||||
Firefox ESR
|
Firefox ESR
|
||||||
|
not dead
|
||||||
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
not IE 9-11 # For IE 9-11 support, remove 'not'.
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
@ -560,24 +549,36 @@ not IE 9-11 # For IE 9-11 support, remove 'not'.
|
|||||||
|
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
|
The default configuration creates two builds, with differential loading enabled.
|
||||||
|
|
||||||
<div class="alert is-important">
|
<div class="alert is-important">
|
||||||
|
|
||||||
To see which browsers are supported and determine which settings meet to your browser support requirements, see the [Browserslist compatibility page](https://browserl.ist/?q=%3E+0.5%25%2C+last+2+versions%2C+Firefox+ESR%2C+not+dead%2C+not+IE+9-11).
|
To see which browsers are supported with the default configuration and determine which settings meet to your browser support requirements, see the [Browserslist compatibility page](https://browserl.ist/?q=%3E+0.5%25%2C+last+2+versions%2C+Firefox+ESR%2C+not+dead%2C+not+IE+9-11).
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
The Browserslist configuration allows you to ignore browsers without ES2015 support. In this case, a single build is produced.
|
The `browserslist` configuration allows you to ignore browsers without ES2015 support. In this case, a single build is produced.
|
||||||
|
|
||||||
If your Browserslist configuration includes support for any legacy browsers, the build target in the TypeScript configuration determines whether the build will support differential loading.
|
If your `browserslist` configuration includes support for any legacy browsers, the build target in the TypeScript configuration determines whether the build will support differential loading.
|
||||||
|
|
||||||
{@a configuration-table }
|
{@a configuration-table }
|
||||||
|
|
||||||
| Browserslist | ES target | Build result |
|
| browserslist | ES target | Build result |
|
||||||
| -------- | -------- | -------- |
|
| -------- | -------- | -------- |
|
||||||
| ES5 support disabled | es2015 | Single build, ES5 not required |
|
| ES5 support disabled | es2015 | Single build, ES5 not required |
|
||||||
| ES5 support enabled | es5 | Single build w/conditional polyfills for ES5 only |
|
| ES5 support enabled | es5 | Single build w/conditional polyfills for ES5 only |
|
||||||
| ES5 support enabled | es2015 | Differential loading (two builds w/conditional polyfills) |
|
| ES5 support enabled | es2015 | Differential loading (two builds w/conditional polyfills) |
|
||||||
|
|
||||||
|
|
||||||
|
### Opting out of differential loading
|
||||||
|
|
||||||
|
Differential loading can be explicitly disabled if it causes unexpected issues, or if you need to target ES5 specifically for legacy browser support.
|
||||||
|
|
||||||
|
To explicitly disable differential loading and create an ES5 build:
|
||||||
|
|
||||||
|
- Enable the `dead` or `IE` browsers in the `browserslist` configuration file by removing the `not` keyword in front of them.
|
||||||
|
- To create a single ES5 build, set the target in the `compilerOptions` to `es5`.
|
||||||
|
|
||||||
{@a test-and-serve}
|
{@a test-and-serve}
|
||||||
|
|
||||||
## Local development in older browsers
|
## Local development in older browsers
|
||||||
|
@ -62,7 +62,8 @@ v9 - v12
|
|||||||
| template syntax | [`/deep/`, `>>>`, and `::ng-deep`](#deep-component-style-selector) | <!--v7--> unspecified |
|
| template syntax | [`/deep/`, `>>>`, and `::ng-deep`](#deep-component-style-selector) | <!--v7--> unspecified |
|
||||||
| browser support | [`IE 9 and 10, IE mobile`](#ie-9-10-and-mobile) | <!--v10--> v11 |
|
| browser support | [`IE 9 and 10, IE mobile`](#ie-9-10-and-mobile) | <!--v10--> v11 |
|
||||||
|
|
||||||
For information about Angular CDK and Angular Material deprecations, see the [changelog](https://github.com/angular/components/blob/master/CHANGELOG.md).
|
|
||||||
|
|
||||||
|
|
||||||
## Deprecated APIs
|
## Deprecated APIs
|
||||||
|
|
||||||
|
@ -153,14 +153,14 @@ It marks that `<li>` element (and its children) as the "repeater template":
|
|||||||
<div class="alert is-important">
|
<div class="alert is-important">
|
||||||
|
|
||||||
Don't forget the leading asterisk (\*) in `*ngFor`. It is an essential part of the syntax.
|
Don't forget the leading asterisk (\*) in `*ngFor`. It is an essential part of the syntax.
|
||||||
Read more about `ngFor` and `*` in the [ngFor section](guide/template-syntax#ngfor) of the [Template Syntax](guide/template-syntax) page.
|
Read more about `ngFor` and `*` in the [ngFor section](guide/built-in-directives#ngfor) of the [Built-in directives](guide/built-in-directives) page.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
Notice the `hero` in the `ngFor` double-quoted instruction;
|
Notice the `hero` in the `ngFor` double-quoted instruction;
|
||||||
it is an example of a template input variable. Read
|
it is an example of a template input variable. Read
|
||||||
more about template input variables in the [microsyntax](guide/template-syntax#microsyntax) section of
|
more about template input variables in the [microsyntax](guide/built-in-directives#microsyntax) section of
|
||||||
the [Template Syntax](guide/template-syntax) page.
|
the [Built-in directives](guide/built-in-directives) page.
|
||||||
|
|
||||||
Angular duplicates the `<li>` for each item in the list, setting the `hero` variable
|
Angular duplicates the `<li>` for each item in the list, setting the `hero` variable
|
||||||
to the item (the hero) in the current iteration. Angular uses that variable as the
|
to the item (the hero) in the current iteration. Angular uses that variable as the
|
||||||
@ -255,7 +255,7 @@ To see it in action, add the following paragraph at the bottom of the template:
|
|||||||
<div class="alert is-important">
|
<div class="alert is-important">
|
||||||
|
|
||||||
Don't forget the leading asterisk (\*) in `*ngIf`. It is an essential part of the syntax.
|
Don't forget the leading asterisk (\*) in `*ngIf`. It is an essential part of the syntax.
|
||||||
Read more about `ngIf` and `*` in the [ngIf section](guide/template-syntax#ngIf) of the [Template Syntax](guide/template-syntax) page.
|
Read more about `ngIf` and `*` in the [ngIf section](guide/built-in-directives#ngIf) of the [Built-in directives](guide/built-in-directives) page.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ When the component's list of heroes has more than three items, Angular adds the
|
|||||||
to the DOM and the message appears.
|
to the DOM and the message appears.
|
||||||
If there are three or fewer items, Angular omits the paragraph, so no message appears.
|
If there are three or fewer items, Angular omits the paragraph, so no message appears.
|
||||||
|
|
||||||
For more information, see [template expressions](guide/template-syntax#template-expressions).
|
For more information, see [template expression operators](guide/interpolation#template-expressions).
|
||||||
|
|
||||||
|
|
||||||
<div class="alert is-helpful">
|
<div class="alert is-helpful">
|
||||||
|
@ -131,22 +131,6 @@ The `createComponent()` method returns a reference to the loaded component.
|
|||||||
Use that reference to interact with the component by assigning to its properties or calling its methods.
|
Use that reference to interact with the component by assigning to its properties or calling its methods.
|
||||||
|
|
||||||
|
|
||||||
{@a selector-references}
|
|
||||||
|
|
||||||
|
|
||||||
#### Selector references
|
|
||||||
|
|
||||||
Generally, the Angular compiler generates a `ComponentFactory`
|
|
||||||
for any component referenced in a template. However, there are
|
|
||||||
no selector references in the templates for
|
|
||||||
dynamically loaded components since they load at runtime.
|
|
||||||
|
|
||||||
To ensure that the compiler still generates a factory,
|
|
||||||
add dynamically loaded components to the `NgModule`'s `entryComponents` array:
|
|
||||||
|
|
||||||
<code-example path="dynamic-component-loader/src/app/app.module.ts" region="entry-components" header="src/app/app.module.ts (entry components)"></code-example>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{@a common-interface}
|
{@a common-interface}
|
||||||
|
|
||||||
|
108
aio/content/guide/event-binding.md
Normal file
108
aio/content/guide/event-binding.md
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
# Event binding `(event)`
|
||||||
|
|
||||||
|
Event binding allows you to listen for certain events such as
|
||||||
|
keystrokes, mouse movements, clicks, and touches.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Angular event binding syntax consists of a **target event** name
|
||||||
|
within parentheses on the left of an equal sign, and a quoted
|
||||||
|
template statement on the right.
|
||||||
|
The following event binding listens for the button's click events, calling
|
||||||
|
the component's `onSave()` method whenever a click occurs:
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src='generated/images/guide/template-syntax/syntax-diagram.svg' alt="Syntax diagram">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Target event
|
||||||
|
|
||||||
|
As above, the target is the button's click event.
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/app.component.html" region="event-binding-1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Alternatively, use the `on-` prefix, known as the canonical form:
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/app.component.html" region="event-binding-2" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Element events may be the more common targets, but Angular looks first to see if the name matches an event property
|
||||||
|
of a known directive, as it does in the following example:
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/app.component.html" region="custom-directive" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
If the name fails to match an element event or an output property of a known directive,
|
||||||
|
Angular reports an “unknown directive” error.
|
||||||
|
|
||||||
|
## *$event* and event handling statements
|
||||||
|
|
||||||
|
In an event binding, Angular sets up an event handler for the target event.
|
||||||
|
|
||||||
|
When the event is raised, the handler executes the template statement.
|
||||||
|
The template statement typically involves a receiver, which performs an action
|
||||||
|
in response to the event, such as storing a value from the HTML control
|
||||||
|
into a model.
|
||||||
|
|
||||||
|
The binding conveys information about the event. This information can include data values such as an event object, string, or number named `$event`.
|
||||||
|
|
||||||
|
The target event determines the shape of the `$event` object.
|
||||||
|
If the target event is a native DOM element event, then `$event` is a
|
||||||
|
[DOM event object](https://developer.mozilla.org/en-US/docs/Web/Events),
|
||||||
|
with properties such as `target` and `target.value`.
|
||||||
|
|
||||||
|
Consider this example:
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/app.component.html" region="event-binding-3" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
This code sets the `<input>` `value` property by binding to the `name` property.
|
||||||
|
To listen for changes to the value, the code binds to the `input`
|
||||||
|
event of the `<input>` element.
|
||||||
|
When the user makes changes, the `input` event is raised, and the binding executes
|
||||||
|
the statement within a context that includes the DOM event object, `$event`.
|
||||||
|
|
||||||
|
To update the `name` property, the changed text is retrieved by following the path `$event.target.value`.
|
||||||
|
|
||||||
|
If the event belongs to a directive—recall that components
|
||||||
|
are directives—`$event` has whatever shape the directive produces.
|
||||||
|
|
||||||
|
## Custom events with `EventEmitter`
|
||||||
|
|
||||||
|
Directives typically raise custom events with an Angular [EventEmitter](api/core/EventEmitter).
|
||||||
|
The directive creates an `EventEmitter` and exposes it as a property.
|
||||||
|
The directive calls `EventEmitter.emit(payload)` to fire an event, passing in a message payload, which can be anything.
|
||||||
|
Parent directives listen for the event by binding to this property and accessing the payload through the `$event` object.
|
||||||
|
|
||||||
|
Consider an `ItemDetailComponent` that presents item information and responds to user actions.
|
||||||
|
Although the `ItemDetailComponent` has a delete button, it doesn't know how to delete the hero. It can only raise an event reporting the user's delete request.
|
||||||
|
|
||||||
|
Here are the pertinent excerpts from that `ItemDetailComponent`:
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/item-detail/item-detail.component.html" header="src/app/item-detail/item-detail.component.html (template)" region="line-through"></code-example>
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/item-detail/item-detail.component.ts" header="src/app/item-detail/item-detail.component.ts (deleteRequest)" region="deleteRequest"></code-example>
|
||||||
|
|
||||||
|
The component defines a `deleteRequest` property that returns an `EventEmitter`.
|
||||||
|
When the user clicks *delete*, the component invokes the `delete()` method,
|
||||||
|
telling the `EventEmitter` to emit an `Item` object.
|
||||||
|
|
||||||
|
Now imagine a hosting parent component that binds to the `deleteRequest` event
|
||||||
|
of the `ItemDetailComponent`.
|
||||||
|
|
||||||
|
<code-example path="event-binding/src/app/app.component.html" header="src/app/app.component.html (event-binding-to-component)" region="event-binding-to-component"></code-example>
|
||||||
|
|
||||||
|
When the `deleteRequest` event fires, Angular calls the parent component's
|
||||||
|
`deleteItem()` method, passing the *item-to-delete* (emitted by `ItemDetail`)
|
||||||
|
in the `$event` variable.
|
||||||
|
|
||||||
|
## Template statements have side effects
|
||||||
|
|
||||||
|
Though [template expressions](guide/interpolation#template-expressions) shouldn't have [side effects](guide/property-binding#avoid-side-effects), template
|
||||||
|
statements usually do. The `deleteItem()` method does have
|
||||||
|
a side effect: it deletes an item.
|
||||||
|
|
||||||
|
Deleting an item updates the model, and depending on your code, triggers
|
||||||
|
other changes including queries and saving to a remote server.
|
||||||
|
These changes propagate through the system and ultimately display in this and other views.
|
@ -55,7 +55,7 @@ This initial root-level application is the *default app* for CLI commands (unles
|
|||||||
|
|
||||||
<div class="alert is-helpful">
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
Besides using the CLI on the command line, you can also use an interactive development environment like [Angular Console](https://angularconsole.com/), or manipulate files directly in the app's source folder and configuration files.
|
Besides using the CLI on the command line, you can also manipulate files directly in the app's source folder and configuration files.
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ This tutorial teaches you how to do the following:
|
|||||||
* Use `ngModel` to create two-way data bindings for reading and writing input-control values.
|
* Use `ngModel` to create two-way data bindings for reading and writing input-control values.
|
||||||
* Provide visual feedback using special CSS classes that track the state of the controls.
|
* Provide visual feedback using special CSS classes that track the state of the controls.
|
||||||
* Display validation errors to users and enable or disable form controls based on the form status.
|
* Display validation errors to users and enable or disable form controls based on the form status.
|
||||||
* Share information across HTML elements using [template reference variables](guide/template-syntax#template-reference-variables-var).
|
* Share information across HTML elements using [template reference variables](guide/template-reference-variables).
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ The note reminds you to remove the diagnostic lines when you have finished obser
|
|||||||
|
|
||||||
When you imported the `FormsModule` in your component, Angular automatically created and attached an [NgForm](api/forms/NgForm "API reference for NgForm") directive to the `<form>` tag in the template (because `NgForm` has the selector `form` that matches `<form>` elements).
|
When you imported the `FormsModule` in your component, Angular automatically created and attached an [NgForm](api/forms/NgForm "API reference for NgForm") directive to the `<form>` tag in the template (because `NgForm` has the selector `form` that matches `<form>` elements).
|
||||||
|
|
||||||
To get access to the `NgForm` and the overall form status, declare a [template reference variable](guide/template-syntax#template-reference-variables-var).
|
To get access to the `NgForm` and the overall form status, declare a [template reference variable](guide/template-reference-variables).
|
||||||
|
|
||||||
1. Edit the template file `hero-form.component.html`.
|
1. Edit the template file `hero-form.component.html`.
|
||||||
|
|
||||||
|
@ -210,6 +210,7 @@ An Angular component class is responsible for exposing data and handling most of
|
|||||||
|
|
||||||
Read more about component classes, templates, and views in [Introduction to Angular concepts](guide/architecture).
|
Read more about component classes, templates, and views in [Introduction to Angular concepts](guide/architecture).
|
||||||
|
|
||||||
|
|
||||||
## configuration
|
## configuration
|
||||||
|
|
||||||
See [workspace configuration](#cli-config)
|
See [workspace configuration](#cli-config)
|
||||||
@ -252,15 +253,15 @@ Data binding is an alternative to manually pushing application data values into
|
|||||||
event listeners, pulling changed values from the screen, and
|
event listeners, pulling changed values from the screen, and
|
||||||
updating application data values.
|
updating application data values.
|
||||||
|
|
||||||
Read about the following forms of binding in [Template Syntax](guide/template-syntax):
|
Read about the following forms of binding in Angular's [Template Syntax](guide/template-syntax):
|
||||||
|
|
||||||
* [Interpolation](guide/template-syntax#interpolation)
|
* [Interpolation](guide/interpolation)
|
||||||
* [Property binding](guide/template-syntax#property-binding)
|
* [Property binding](guide/property-binding)
|
||||||
* [Event binding](guide/template-syntax#event-binding)
|
* [Event binding](guide/event-binding)
|
||||||
* [Attribute binding](guide/template-syntax#attribute-binding)
|
* [Attribute binding](guide/attribute-binding)
|
||||||
* [Class binding](guide/template-syntax#class-binding)
|
* [Class binding](guide/attribute-binding#class-binding)
|
||||||
* [Style binding](guide/template-syntax#style-binding)
|
* [Style binding](guide/attribute-binding#style-binding)
|
||||||
* [Two-way data binding with ngModel](guide/template-syntax#ngModel)
|
* [Two-way data binding with ngModel](guide/built-in-directives#ngModel)
|
||||||
|
|
||||||
{@a declarable}
|
{@a declarable}
|
||||||
|
|
||||||
@ -472,11 +473,11 @@ Learn more about the injector hierarchy in [Hierarchical Dependency Injectors](g
|
|||||||
## input
|
## input
|
||||||
|
|
||||||
When defining a [directive](#directive), the `@Input()` decorator on a directive property
|
When defining a [directive](#directive), the `@Input()` decorator on a directive property
|
||||||
makes that property available as a *target* of a [property binding](guide/template-syntax#property-binding).
|
makes that property available as a *target* of a [property binding](guide/property-binding).
|
||||||
Data values flow into an input property from the data source identified
|
Data values flow into an input property from the data source identified
|
||||||
in the [template expression](#template-expression) to the right of the equal sign.
|
in the [template expression](#template-expression) to the right of the equal sign.
|
||||||
|
|
||||||
To learn more, see [input and output properties](guide/template-syntax#inputs-outputs).
|
To learn more, see [input and output properties](guide/inputs-outputs).
|
||||||
|
|
||||||
{@a interpolation}
|
{@a interpolation}
|
||||||
|
|
||||||
@ -491,7 +492,7 @@ or displayed between element tags, as in this example.
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
Read more about [interpolation](guide/template-syntax#interpolation) in [Template Syntax](guide/template-syntax).
|
Read more in the [Interpolation](guide/interpolation) guide.
|
||||||
|
|
||||||
{@a ivy}
|
{@a ivy}
|
||||||
|
|
||||||
@ -578,7 +579,6 @@ Angular calls these hook methods in the following order:
|
|||||||
|
|
||||||
To learn more, see [Lifecycle Hooks](guide/lifecycle-hooks).
|
To learn more, see [Lifecycle Hooks](guide/lifecycle-hooks).
|
||||||
|
|
||||||
|
|
||||||
{@a M}
|
{@a M}
|
||||||
|
|
||||||
{@a module}
|
{@a module}
|
||||||
@ -653,11 +653,11 @@ An object passed to the `subscribe()` method for an [observable](#observable). T
|
|||||||
## output
|
## output
|
||||||
|
|
||||||
When defining a [directive](#directive), the `@Output{}` decorator on a directive property
|
When defining a [directive](#directive), the `@Output{}` decorator on a directive property
|
||||||
makes that property available as a *target* of [event binding](guide/template-syntax#event-binding).
|
makes that property available as a *target* of [event binding](guide/event-binding).
|
||||||
Events stream *out* of this property to the receiver identified
|
Events stream *out* of this property to the receiver identified
|
||||||
in the [template expression](#template-expression) to the right of the equal sign.
|
in the [template expression](#template-expression) to the right of the equal sign.
|
||||||
|
|
||||||
To learn more, see [Input and Output Properties](guide/template-syntax#inputs-outputs).
|
To learn more, see [Input and Output Properties](guide/inputs-outputs).
|
||||||
|
|
||||||
|
|
||||||
{@a P}
|
{@a P}
|
||||||
@ -739,6 +739,26 @@ When using reactive forms:
|
|||||||
|
|
||||||
The alternative is a template-driven form. For an introduction and comparison of both forms approaches, see [Introduction to Angular Forms](guide/forms-overview).
|
The alternative is a template-driven form. For an introduction and comparison of both forms approaches, see [Introduction to Angular Forms](guide/forms-overview).
|
||||||
|
|
||||||
|
{@a resolver}
|
||||||
|
|
||||||
|
## resolver
|
||||||
|
|
||||||
|
A class that implements the [Resolve](api/router/Resolve "API reference") interface (or a function with the same signature as the [resolve() method](api/router/Resolve#resolve "API reference")) that you use to produce or retrieve data that is needed before navigation to a requested route can be completed.
|
||||||
|
|
||||||
|
Resolvers run after all [route guards](#route-guard "Definition") for a route tree have been executed and have succeeded.
|
||||||
|
|
||||||
|
See an example of using a [resolve guard](guide/router-tutorial-toh#resolve-guard "Routing techniques tutorial") to retrieve dynamic data.
|
||||||
|
|
||||||
|
{@a route-guard}
|
||||||
|
|
||||||
|
## route guard
|
||||||
|
|
||||||
|
A method that controls navigation to a requested route in a routing application.
|
||||||
|
Guards determine whether a route can be activated or deactivated, and whether a lazy-loaded module can be loaded.
|
||||||
|
|
||||||
|
Learn more in the [Routing and Navigation](guide/router#preventing-unauthorized-access "Examples") guide.
|
||||||
|
|
||||||
|
|
||||||
{@a router}
|
{@a router}
|
||||||
{@a router-module}
|
{@a router-module}
|
||||||
|
|
||||||
@ -917,7 +937,20 @@ The alternative is a reactive form. For an introduction and comparison of both f
|
|||||||
|
|
||||||
A TypeScript-like syntax that Angular evaluates within a [data binding](#data-binding).
|
A TypeScript-like syntax that Angular evaluates within a [data binding](#data-binding).
|
||||||
|
|
||||||
Read about how to write template expressions in [Template expressions](guide/template-syntax#template-expressions).
|
Read about how to write template expressions in the [template expressions](guide/interpolation#template-expressions) section of the [Interpolation](guide/interpolation) guide.
|
||||||
|
|
||||||
|
{@a template-reference-variable}
|
||||||
|
|
||||||
|
## template reference variable
|
||||||
|
|
||||||
|
A variable defined in a template that references an instance associated with an element, such as a directive instance, component instance, template as in `TemplateRef`, or DOM element.
|
||||||
|
After declaring a template reference variable on an element in a template,
|
||||||
|
you can access values from that variable elsewhere within the same template.
|
||||||
|
The following example defines a template reference variable named `#phone`.
|
||||||
|
|
||||||
|
<code-example path="template-reference-variables/src/app/app.component.html" region="ref-var" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
For more information, see the [Template reference variable](guide/template-reference-variables) guide.
|
||||||
|
|
||||||
{@a token}
|
{@a token}
|
||||||
|
|
||||||
|
342
aio/content/guide/inputs-outputs.md
Normal file
342
aio/content/guide/inputs-outputs.md
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
# `@Input()` and `@Output()` properties
|
||||||
|
|
||||||
|
`@Input()` and `@Output()` allow Angular to share data between the parent context
|
||||||
|
and child directives or components. An `@Input()` property is writable
|
||||||
|
while an `@Output()` property is observable.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Consider this example of a child/parent relationship:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<parent-component>
|
||||||
|
<child-component></child-component>
|
||||||
|
</parent-component>
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Here, the `<child-component>` selector, or child directive, is embedded
|
||||||
|
within a `<parent-component>`, which serves as the child's context.
|
||||||
|
|
||||||
|
`@Input()` and `@Output()` act as
|
||||||
|
the API, or application programming interface, of the child
|
||||||
|
component in that they allow the child to
|
||||||
|
communicate with the parent. Think of `@Input()` and `@Output()` like ports
|
||||||
|
or doorways—`@Input()` is the doorway into the component allowing data
|
||||||
|
to flow in while `@Output()` is the doorway out of the component, allowing the
|
||||||
|
child component to send data out.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
#### `@Input()` and `@Output()` are independent
|
||||||
|
|
||||||
|
Though `@Input()` and `@Output()` often appear together in apps, you can use
|
||||||
|
them separately. If the nested
|
||||||
|
component is such that it only needs to send data to its parent, you wouldn't
|
||||||
|
need an `@Input()`, only an `@Output()`. The reverse is also true in that if the
|
||||||
|
child only needs to receive data from the parent, you'd only need `@Input()`.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a input}
|
||||||
|
|
||||||
|
## How to use `@Input()`
|
||||||
|
|
||||||
|
Use the `@Input()` decorator in a child component or directive to let Angular know
|
||||||
|
that a property in that component can receive its value from its parent component.
|
||||||
|
It helps to remember that the data flow is from the perspective of the
|
||||||
|
child component. So an `@Input()` allows data to be input _into_ the
|
||||||
|
child component from the parent component.
|
||||||
|
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src="generated/images/guide/inputs-outputs/input.svg" alt="Input data flow diagram">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
To illustrate the use of `@Input()`, edit these parts of your app:
|
||||||
|
|
||||||
|
* The child component class and template
|
||||||
|
* The parent component class and template
|
||||||
|
|
||||||
|
|
||||||
|
### In the child
|
||||||
|
|
||||||
|
To use the `@Input()` decorator in a child component class, first import
|
||||||
|
`Input` and then decorate the property with `@Input()`:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/item-detail/item-detail.component.ts" region="use-input" header="src/app/item-detail/item-detail.component.ts"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
In this case, `@Input()` decorates the property <code class="no-auto-link">item</code>, which has
|
||||||
|
a type of `string`, however, `@Input()` properties can have any type, such as
|
||||||
|
`number`, `string`, `boolean`, or `object`. The value for `item` will come from the parent component, which the next section covers.
|
||||||
|
|
||||||
|
Next, in the child component template, add the following:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/item-detail/item-detail.component.html" region="property-in-template" header="src/app/item-detail/item-detail.component.html"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### In the parent
|
||||||
|
|
||||||
|
The next step is to bind the property in the parent component's template.
|
||||||
|
In this example, the parent component template is `app.component.html`.
|
||||||
|
|
||||||
|
First, use the child's selector, here `<app-item-detail>`, as a directive within the
|
||||||
|
parent component template. Then, use [property binding](guide/property-binding)
|
||||||
|
to bind the property in the child to the property of the parent.
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/app.component.html" region="input-parent" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Next, in the parent component class, `app.component.ts`, designate a value for `currentItem`:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/app.component.ts" region="parent-property" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
With `@Input()`, Angular passes the value for `currentItem` to the child so that `item` renders as `Television`.
|
||||||
|
|
||||||
|
The following diagram shows this structure:
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src="generated/images/guide/inputs-outputs/input-diagram-target-source.svg" alt="Property binding diagram">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The target in the square brackets, `[]`, is the property you decorate
|
||||||
|
with `@Input()` in the child component. The binding source, the part
|
||||||
|
to the right of the equal sign, is the data that the parent
|
||||||
|
component passes to the nested component.
|
||||||
|
|
||||||
|
The key takeaway is that when binding to a child component's property in a parent component—that is, what's
|
||||||
|
in square brackets—you must
|
||||||
|
decorate the property with `@Input()` in the child component.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
### `OnChanges` and `@Input()`
|
||||||
|
|
||||||
|
To watch for changes on an `@Input()` property, use
|
||||||
|
`OnChanges`, one of Angular's [lifecycle hooks](guide/lifecycle-hooks#onchanges).
|
||||||
|
`OnChanges` is specifically designed to work with properties that have the
|
||||||
|
`@Input()` decorator. See the [`OnChanges`](guide/lifecycle-hooks#onchanges) section of the [Lifecycle Hooks](guide/lifecycle-hooks) guide for more details and examples.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a output}
|
||||||
|
|
||||||
|
## How to use `@Output()`
|
||||||
|
|
||||||
|
Use the `@Output()` decorator in the child component or directive to allow data to flow from
|
||||||
|
the child _out_ to the parent.
|
||||||
|
|
||||||
|
An `@Output()` property should normally be initialized to an Angular [`EventEmitter`](api/core/EventEmitter) with values flowing out of the component as [events](guide/event-binding).
|
||||||
|
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src="generated/images/guide/inputs-outputs/output.svg" alt="Output diagram">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Just like with `@Input()`, you can use `@Output()`
|
||||||
|
on a property of the child component but its type should be
|
||||||
|
`EventEmitter`.
|
||||||
|
|
||||||
|
`@Output()` marks a property in a child component as a doorway
|
||||||
|
through which data can travel from the child to the parent.
|
||||||
|
The child component then has to raise an event so the
|
||||||
|
parent knows something has changed. To raise an event,
|
||||||
|
`@Output()` works hand in hand with `EventEmitter`,
|
||||||
|
which is a class in `@angular/core` that you
|
||||||
|
use to emit custom events.
|
||||||
|
|
||||||
|
When you use `@Output()`, edit these parts of your app:
|
||||||
|
|
||||||
|
* The child component class and template
|
||||||
|
* The parent component class and template
|
||||||
|
|
||||||
|
|
||||||
|
The following example shows how to set up an `@Output()` in a child
|
||||||
|
component that pushes data you enter in an HTML `<input>` to an array in the
|
||||||
|
parent component.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
The HTML element `<input>` and the Angular decorator `@Input()`
|
||||||
|
are different. This documentation is about component communication in Angular as it pertains to `@Input()` and `@Output()`. For more information on the HTML element `<input>`, see the [W3C Recommendation](https://www.w3.org/TR/html5/sec-forms.html#the-input-element).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## In the child
|
||||||
|
|
||||||
|
This example features an `<input>` where a user can enter a value and click a `<button>` that raises an event. The `EventEmitter` then relays the data to the parent component.
|
||||||
|
|
||||||
|
First, be sure to import `Output` and `EventEmitter`
|
||||||
|
in the child component class:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Output, EventEmitter } from '@angular/core';
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, still in the child, decorate a property with `@Output()` in the component class.
|
||||||
|
The following example `@Output()` is called `newItemEvent` and its type is
|
||||||
|
`EventEmitter`, which means it's an event.
|
||||||
|
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/item-output/item-output.component.ts" region="item-output" header="src/app/item-output/item-output.component.ts"></code-example>
|
||||||
|
|
||||||
|
The different parts of the above declaration are as follows:
|
||||||
|
|
||||||
|
* `@Output()`—a decorator function marking the property as a way for data to go from the child to the parent
|
||||||
|
* `newItemEvent`—the name of the `@Output()`
|
||||||
|
* `EventEmitter<string>`—the `@Output()`'s type
|
||||||
|
* `new EventEmitter<string>()`—tells Angular to create a new event emitter and that the data it emits is of type string. The type could be any type, such as `number`, `boolean`, and so on. For more information on `EventEmitter`, see the [EventEmitter API documentation](api/core/EventEmitter).
|
||||||
|
|
||||||
|
Next, create an `addNewItem()` method in the same component class:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/item-output/item-output.component.ts" region="item-output-class" header="src/app/item-output/item-output.component.ts"></code-example>
|
||||||
|
|
||||||
|
The `addNewItem()` function uses the `@Output()`, `newItemEvent`,
|
||||||
|
to raise an event in which it emits the value the user
|
||||||
|
types into the `<input>`. In other words, when
|
||||||
|
the user clicks the add button in the UI, the child lets the parent know
|
||||||
|
about the event and gives that data to the parent.
|
||||||
|
|
||||||
|
### In the child's template
|
||||||
|
|
||||||
|
The child's template has two controls. The first is an HTML `<input>` with a
|
||||||
|
[template reference variable](guide/template-reference-variables) , `#newItem`,
|
||||||
|
where the user types in an item name. Whatever the user types
|
||||||
|
into the `<input>` gets stored in the `#newItem` variable.
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/item-output/item-output.component.html" region="child-output" header="src/app/item-output/item-output.component.html"></code-example>
|
||||||
|
|
||||||
|
The second element is a `<button>`
|
||||||
|
with an [event binding](guide/event-binding). You know it's
|
||||||
|
an event binding because the part to the left of the equal
|
||||||
|
sign is in parentheses, `(click)`.
|
||||||
|
|
||||||
|
The `(click)` event is bound to the `addNewItem()` method in the child component class which
|
||||||
|
takes as its argument whatever the value of `#newItem` is.
|
||||||
|
|
||||||
|
Now the child component has an `@Output()`
|
||||||
|
for sending data to the parent and a method for raising an event.
|
||||||
|
The next step is in the parent.
|
||||||
|
|
||||||
|
## In the parent
|
||||||
|
|
||||||
|
In this example, the parent component is `AppComponent`, but you could use
|
||||||
|
any component in which you could nest the child.
|
||||||
|
|
||||||
|
The `AppComponent` in this example features a list of `items`
|
||||||
|
in an array and a method for adding more items to the array.
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/app.component.ts" region="add-new-item" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
The `addItem()` method takes an argument in the form of a string
|
||||||
|
and then pushes, or adds, that string to the `items` array.
|
||||||
|
|
||||||
|
### In the parent's template
|
||||||
|
|
||||||
|
Next, in the parent's template, bind the parent's
|
||||||
|
method to the child's event. Put the child selector, here `<app-item-output>`,
|
||||||
|
within the parent component's
|
||||||
|
template, `app.component.html`.
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/app.component.html" region="output-parent" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The event binding, `(newItemEvent)='addItem($event)'`, tells
|
||||||
|
Angular to connect the event in the child, `newItemEvent`, to
|
||||||
|
the method in the parent, `addItem()`, and that the event that the child
|
||||||
|
is notifying the parent about is to be the argument of `addItem()`.
|
||||||
|
In other words, this is where the actual hand off of data takes place.
|
||||||
|
The `$event` contains the data that the user types into the `<input>`
|
||||||
|
in the child template UI.
|
||||||
|
|
||||||
|
Now, in order to see the `@Output()` working, add the following to the parent's template:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<ul>
|
||||||
|
<li *ngFor="let item of items">{{item}}</li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
The `*ngFor` iterates over the items in the `items` array. When you enter a value in the child's `<input>` and click the button, the child emits the event and the parent's `addItem()` method pushes the value to the `items` array and it renders in the list.
|
||||||
|
|
||||||
|
|
||||||
|
## `@Input()` and `@Output()` together
|
||||||
|
|
||||||
|
You can use `@Input()` and `@Output()` on the same child component as in the following:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/app.component.html" region="together" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The target, `item`, which is an `@Input()` property in the child component class, receives its value from the parent's property, `currentItem`. When you click delete, the child component raises an event, `deleteRequest`, which is the argument for the parent's `crossOffItem()` method.
|
||||||
|
|
||||||
|
The following diagram is of an `@Input()` and an `@Output()` on the same
|
||||||
|
child component and shows the different parts of each:
|
||||||
|
|
||||||
|
<div class="lightbox">
|
||||||
|
<img src="generated/images/guide/inputs-outputs/input-output-diagram.svg" alt="Input/Output diagram">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
As the diagram shows, use inputs and outputs together in the same manner as using them separately. Here, the child selector is `<app-input-output>` with `item` and `deleteRequest` being `@Input()` and `@Output()`
|
||||||
|
properties in the child component class. The property `currentItem` and the method `crossOffItem()` are both in the parent component class.
|
||||||
|
|
||||||
|
To combine property and event bindings using the banana-in-a-box
|
||||||
|
syntax, `[()]`, see [Two-way Binding](guide/two-way-binding).
|
||||||
|
|
||||||
|
## `@Input()` and `@Output()` declarations
|
||||||
|
|
||||||
|
Instead of using the `@Input()` and `@Output()` decorators
|
||||||
|
to declare inputs and outputs, you can identify
|
||||||
|
members in the `inputs` and `outputs` arrays
|
||||||
|
of the directive metadata, as in this example:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/in-the-metadata/in-the-metadata.component.ts" region="metadata" header="src/app/in-the-metadata/in-the-metadata.component.ts"></code-example>
|
||||||
|
|
||||||
|
While declaring `inputs` and `outputs` in the `@Directive` and `@Component`
|
||||||
|
metadata is possible, it is a better practice to use the `@Input()` and `@Output()`
|
||||||
|
class decorators instead, as follows:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/input-output/input-output.component.ts" region="input-output" header="src/app/input-output/input-output.component.ts"></code-example>
|
||||||
|
|
||||||
|
See the [Decorate input and output properties](guide/styleguide#decorate-input-and-output-properties) section of the
|
||||||
|
[Style Guide](guide/styleguide) for details.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
If you get a template parse error when trying to use inputs or outputs, but you know that the
|
||||||
|
properties do indeed exist, double check
|
||||||
|
that your properties are annotated with `@Input()` / `@Output()` or that you've declared
|
||||||
|
them in an `inputs`/`outputs` array:
|
||||||
|
|
||||||
|
<code-example language="bash">
|
||||||
|
Uncaught Error: Template parse errors:
|
||||||
|
Can't bind to 'item' since it isn't a known property of 'app-item-detail'
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a aliasing-io}
|
||||||
|
|
||||||
|
## Aliasing inputs and outputs
|
||||||
|
|
||||||
|
Sometimes the public name of an input/output property should be different from the internal name. While it is a best practice to avoid this situation, Angular does
|
||||||
|
offer a solution.
|
||||||
|
|
||||||
|
### Aliasing in the metadata
|
||||||
|
|
||||||
|
Alias inputs and outputs in the metadata using a colon-delimited (`:`) string with
|
||||||
|
the directive property name on the left and the public alias on the right:
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/aliasing/aliasing.component.ts" region="alias" header="src/app/aliasing/aliasing.component.ts"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
### Aliasing with the `@Input()`/`@Output()` decorator
|
||||||
|
|
||||||
|
You can specify the alias for the property name by passing the alias name to the `@Input()`/`@Output()` decorator. The internal name remains as usual.
|
||||||
|
|
||||||
|
<code-example path="inputs-outputs/src/app/aliasing/aliasing.component.ts" region="alias-input-output" header="src/app/aliasing/aliasing.component.ts"></code-example>
|
175
aio/content/guide/interpolation.md
Normal file
175
aio/content/guide/interpolation.md
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
# Interpolation and template expressions
|
||||||
|
|
||||||
|
Interpolation allows you to incorporate calculated strings into the text
|
||||||
|
between HTML element tags and within attribute assignments. Template
|
||||||
|
expressions are what you use to calculate those strings.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for all of
|
||||||
|
the syntax and code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Interpolation `{{...}}`
|
||||||
|
|
||||||
|
Interpolation refers to embedding expressions into marked up text.
|
||||||
|
By default, interpolation uses as its delimiter the double curly braces, `{{` and `}}`.
|
||||||
|
|
||||||
|
In the following snippet, `{{ currentCustomer }}` is an example of interpolation.
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="interpolation-example1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The text between the braces is often the name of a component
|
||||||
|
property. Angular replaces that name with the
|
||||||
|
string value of the corresponding component property.
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="component-property" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
In the example above, Angular evaluates the `title` and `itemImageUrl` properties
|
||||||
|
and fills in the blanks, first displaying some title text and then an image.
|
||||||
|
|
||||||
|
More generally, the text between the braces is a **template expression**
|
||||||
|
that Angular first **evaluates** and then **converts to a string**.
|
||||||
|
The following interpolation illustrates the point by adding two numbers:
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="convert-string" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The expression can invoke methods of the host component such as `getVal()` in
|
||||||
|
the following example:
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="invoke-method" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Angular evaluates all expressions in double curly braces,
|
||||||
|
converts the expression results to strings, and links them with neighboring literal strings. Finally,
|
||||||
|
it assigns this composite interpolated result to an **element or directive property**.
|
||||||
|
|
||||||
|
You appear to be inserting the result between element tags and assigning it to attributes.
|
||||||
|
However, interpolation is a special syntax that Angular converts into a *property binding*.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
If you'd like to use something other than `{{` and `}}`, you can
|
||||||
|
configure the interpolation delimiter via the
|
||||||
|
[interpolation](api/core/Component#interpolation)
|
||||||
|
option in the `Component` metadata.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Template expressions
|
||||||
|
|
||||||
|
A template **expression** produces a value and appears within the double
|
||||||
|
curly braces, `{{ }}`.
|
||||||
|
Angular executes the expression and assigns it to a property of a binding target;
|
||||||
|
the target could be an HTML element, a component, or a directive.
|
||||||
|
|
||||||
|
The interpolation braces in `{{1 + 1}}` surround the template expression `1 + 1`.
|
||||||
|
In the property binding,
|
||||||
|
a template expression appears in quotes to the right of the `=` symbol as in `[property]="expression"`.
|
||||||
|
|
||||||
|
In terms of syntax, template expressions are similar to JavaScript.
|
||||||
|
Many JavaScript expressions are legal template expressions, with a few exceptions.
|
||||||
|
|
||||||
|
You can't use JavaScript expressions that have or promote side effects,
|
||||||
|
including:
|
||||||
|
|
||||||
|
* Assignments (`=`, `+=`, `-=`, `...`)
|
||||||
|
* Operators such as `new`, `typeof`, `instanceof`, etc.
|
||||||
|
* Chaining expressions with <code>;</code> or <code>,</code>
|
||||||
|
* The increment and decrement operators `++` and `--`
|
||||||
|
* Some of the ES2015+ operators
|
||||||
|
|
||||||
|
Other notable differences from JavaScript syntax include:
|
||||||
|
|
||||||
|
* No support for the bitwise operators such as `|` and `&`
|
||||||
|
* New [template expression operators](guide/template-expression-operators), such as `|`, `?.` and `!`
|
||||||
|
|
||||||
|
|
||||||
|
## Expression context
|
||||||
|
|
||||||
|
The *expression context* is typically the _component_ instance.
|
||||||
|
In the following snippets, the `recommended` within double curly braces and the
|
||||||
|
`itemImageUrl2` in quotes refer to properties of the `AppComponent`.
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="component-context" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
An expression may also refer to properties of the _template's_ context
|
||||||
|
such as a template input variable,
|
||||||
|
<!-- link to built-in-directives#template-input-variables -->
|
||||||
|
`let customer`, or a template reference variable, `#customerInput`.
|
||||||
|
<!-- link to guide/template-ref-variables -->
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="template-input-variable" header="src/app/app.component.html (template input variable)"></code-example>
|
||||||
|
|
||||||
|
<code-example path="interpolation/src/app/app.component.html" region="template-reference-variable" header="src/app/app.component.html (template reference variable)"></code-example>
|
||||||
|
|
||||||
|
The context for terms in an expression is a blend of the _template variables_,
|
||||||
|
the directive's _context_ object (if it has one), and the component's _members_.
|
||||||
|
If you reference a name that belongs to more than one of these namespaces,
|
||||||
|
the template variable name takes precedence, followed by a name in the directive's _context_,
|
||||||
|
and, lastly, the component's member names.
|
||||||
|
|
||||||
|
The previous example presents such a name collision. The component has a `customer`
|
||||||
|
property and the `*ngFor` defines a `customer` template variable.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
The `customer` in `{{customer.name}}`
|
||||||
|
refers to the template input variable, not the component's property.
|
||||||
|
|
||||||
|
Template expressions cannot refer to anything in
|
||||||
|
the global namespace, except `undefined`. They can't refer to
|
||||||
|
`window` or `document`. Additionally, they
|
||||||
|
can't call `console.log()` or `Math.max()` and they are restricted to referencing
|
||||||
|
members of the expression context.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Expression guidelines
|
||||||
|
|
||||||
|
When using template expressions follow these guidelines:
|
||||||
|
|
||||||
|
* [Simplicity](guide/interpolation#simplicity)
|
||||||
|
* [Quick execution](guide/interpolation#quick-execution)
|
||||||
|
* [No visible side effects](guide/interpolation#no-visible-side-effects)
|
||||||
|
|
||||||
|
### Simplicity
|
||||||
|
|
||||||
|
Although it's possible to write complex template expressions, it's a better
|
||||||
|
practice to avoid them.
|
||||||
|
|
||||||
|
A property name or method call should be the norm, but an occasional Boolean negation, `!`, is OK.
|
||||||
|
Otherwise, confine application and business logic to the component,
|
||||||
|
where it is easier to develop and test.
|
||||||
|
|
||||||
|
### Quick execution
|
||||||
|
|
||||||
|
Angular executes template expressions after every change detection cycle.
|
||||||
|
Change detection cycles are triggered by many asynchronous activities such as
|
||||||
|
promise resolutions, HTTP results, timer events, key presses and mouse moves.
|
||||||
|
|
||||||
|
Expressions should finish quickly or the user experience may drag, especially on slower devices.
|
||||||
|
Consider caching values when their computation is expensive.
|
||||||
|
|
||||||
|
### No visible side effects
|
||||||
|
|
||||||
|
A template expression should not change any application state other than the value of the
|
||||||
|
target property.
|
||||||
|
|
||||||
|
This rule is essential to Angular's "unidirectional data flow" policy.
|
||||||
|
You should never worry that reading a component value might change some other displayed value.
|
||||||
|
The view should be stable throughout a single rendering pass.
|
||||||
|
|
||||||
|
An [idempotent](https://en.wikipedia.org/wiki/Idempotence) expression is ideal because
|
||||||
|
it is free of side effects and improves Angular's change detection performance.
|
||||||
|
In Angular terms, an idempotent expression always returns
|
||||||
|
*exactly the same thing* until one of its dependent values changes.
|
||||||
|
|
||||||
|
Dependent values should not change during a single turn of the event loop.
|
||||||
|
If an idempotent expression returns a string or a number, it returns the same string or number when called twice in a row. If the expression returns an object, including an `array`, it returns the same object *reference* when called twice in a row.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
There is one exception to this behavior that applies to `*ngFor`. `*ngFor` has `trackBy` functionality that can deal with referential inequality of objects when iterating over them. See [*ngFor with `trackBy`](guide/built-in-directives#ngfor-with-trackby) for details.
|
||||||
|
|
||||||
|
</div>
|
@ -569,7 +569,7 @@ which can only be reached by querying for them via the property decorated with
|
|||||||
|
|
||||||
{@a no-unidirectional-flow-worries}
|
{@a no-unidirectional-flow-worries}
|
||||||
|
|
||||||
<div class="alert is-helpful>
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
<header>No need to wait for content updates</header>
|
<header>No need to wait for content updates</header>
|
||||||
|
|
||||||
|
@ -1,187 +0,0 @@
|
|||||||
# Optimizing client app size with lightweight injection tokens
|
|
||||||
|
|
||||||
This page provides a conceptual overview of a dependency injection technique that is recommended for library developers.
|
|
||||||
Designing your library with *lightweight injection tokens* helps optimize the bundle size of client applications that use your library.
|
|
||||||
|
|
||||||
You can manage the dependency structure among your components and injectable services to optimize bundle size by using [tree-shakable providers](guide/dependency-injection-providers#tree-shakable-providers).
|
|
||||||
This normally ensures that if a provided component or service is never actually used by the app, the compiler can eliminate its code from the bundle.
|
|
||||||
|
|
||||||
However, due to the way Angular stores injection tokens, it is possible that such an unused component or service can end up in the bundle anyway.
|
|
||||||
This page describes a dependency-injection design pattern that supports proper tree-shaking by using lightweight injection tokens.
|
|
||||||
|
|
||||||
The lightweight injection token design pattern is especially important for library developers. It ensures that when an application uses only some of your library's capabilities, the unused code can be eliminated from the client's app bundle.
|
|
||||||
|
|
||||||
When an application uses your library, there might be some services that your library supplies which the client app doesn't use.
|
|
||||||
In this case, the app developer should expect that service to be tree-shaken, and not contribute to the size of the compiled app.
|
|
||||||
Because the application developer cannot know about or remedy a tree-shaking problem in the library, it is the responsibility of the library developer to do so.
|
|
||||||
To prevent the retention of unused components, your library should use the lightweight injection token design pattern.
|
|
||||||
|
|
||||||
## When tokens are retained
|
|
||||||
|
|
||||||
To better explain the condition under which token retention occurs, consider a library that provides a library-card component, which contains a body and can contain an optional header.
|
|
||||||
|
|
||||||
```
|
|
||||||
<lib-card>
|
|
||||||
<lib-header>...</lib-header>
|
|
||||||
</lib-card>
|
|
||||||
```
|
|
||||||
|
|
||||||
In a likely implementation, the `<lib-card>` component uses `@ContentChild()` or `@ContentChildren()` to obtain `<lib-header>` and `<lib-body>`, as in the following.
|
|
||||||
|
|
||||||
```
|
|
||||||
@Component({
|
|
||||||
selector: 'lib-header',
|
|
||||||
...,
|
|
||||||
})
|
|
||||||
class LibHeaderComponent {}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'lib-card',
|
|
||||||
...,
|
|
||||||
})
|
|
||||||
class LibCardComponent {
|
|
||||||
@ContentChild(LibHeaderComponent)
|
|
||||||
header: LibHeaderComponent|null = null;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Because `<lib-header>` is optional, the element can appear in the template in its minimal form,
|
|
||||||
`<lib-card></lib-card>`.
|
|
||||||
In this case, `<lib-header>` is not used and you would expect it to be tree-shaken, but that is not what happens.
|
|
||||||
This is because `LibCardComponent` actually contains two references to the `LibHeaderComponent`.
|
|
||||||
|
|
||||||
`@ContentChild(LibHeaderComponent) header: LibHeaderComponent;`
|
|
||||||
|
|
||||||
* One of these reference is in the *type position*-- that is, it specifies `LibHeaderComponent` as a type: `header: LibHeaderComponent;`.
|
|
||||||
|
|
||||||
* The other reference is in the *value position*-- that is, LibHeaderComponent is the value of the `@ContentChild()` parameter decorator: `@ContentChild(LibHeaderComponent)`.
|
|
||||||
|
|
||||||
The compiler handles token references in these positions differently.
|
|
||||||
|
|
||||||
* The compiler erases *type position* references after conversion from TypeScript, so they have no impact on tree-shaking.
|
|
||||||
|
|
||||||
* The compiler must retain *value position* references at runtime, which prevents the component from being tree-shaken.
|
|
||||||
|
|
||||||
In the example, the compiler retains the `LibHeaderComponent` token that occurs in the value position, which prevents the referenced component from being tree-shaken, even if the application developer does not actually use `<lib-header>` anywhere.
|
|
||||||
If `LibHeaderComponent` is large (code, template, and styles), including it unnecessarily can significantly increase the size of the client application.
|
|
||||||
|
|
||||||
## When to use the lightweight injection token pattern
|
|
||||||
|
|
||||||
The tree-shaking problem arises when a component is used as an injection token.
|
|
||||||
There are two cases when that can happen.
|
|
||||||
|
|
||||||
* The token is used in the value position of a [content query](guide/lifecycle-hooks#using-aftercontent-hooks "See more about using content queries.").
|
|
||||||
* The token is used as a type specifier for constructor injection.
|
|
||||||
|
|
||||||
In the following example, both uses of the `OtherComponent` token cause retention of `OtherComponent` (that is, prevent it from being tree-shaken when it is not used).
|
|
||||||
|
|
||||||
```
|
|
||||||
class MyComponent {
|
|
||||||
constructor(@Optional() other: OtherComponent) {}
|
|
||||||
|
|
||||||
@ContentChild(OtherComponent)
|
|
||||||
other: OtherComponent|null;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Although tokens used only as type specifiers are removed when converted to JavaScript, all tokens used for dependency injection are needed at runtime.
|
|
||||||
These effectively change `constructor(@Optional() other: OtherComponent)` to `constructor(@Optional() @Inject(OtherComponent) other)`. The token is now in a value position, and causes the tree shaker to retain the reference.
|
|
||||||
|
|
||||||
<div class="alert is helpful">
|
|
||||||
|
|
||||||
For all services, a library should use [tree-shakable providers](guide/dependency-injection-providers#tree-shakable-providers), providing dependencies at the root level rather than in component constructors.
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
## Using lightweight injection tokens
|
|
||||||
|
|
||||||
The lightweight injection token design pattern consists of using a small abstract class as an injection token, and providing the actual implementation at a later stage.
|
|
||||||
The abstract class is retained (not tree-shaken), but it is small and has no material impact on the application size.
|
|
||||||
|
|
||||||
The following example shows how this works for the `LibHeaderComponent`.
|
|
||||||
|
|
||||||
```
|
|
||||||
abstract class LibHeaderToken {}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'lib-header',
|
|
||||||
providers: [
|
|
||||||
{provide: LibHeaderToken, useExisting: LibHeaderComponent}
|
|
||||||
]
|
|
||||||
...,
|
|
||||||
})
|
|
||||||
class LibHeaderComponent extends LibHeaderToken {}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'lib-card',
|
|
||||||
...,
|
|
||||||
})
|
|
||||||
class LibCardComponent {
|
|
||||||
@ContentChild(LibHeaderToken) header: LibHeaderToken|null = null;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example, the `LibCardComponent` implementation no longer refers to `LibHeaderComponent` in either the type position or the value position.
|
|
||||||
This allows full tree shaking of `LibHeaderComponent` to take place.
|
|
||||||
The `LibHeaderToken` is retained, but it is only a class declaration, with no concrete implementation. It is small and does not materially impact the application size when retained after compilation.
|
|
||||||
|
|
||||||
Instead, `LibHeaderComponent` itself implements the abstract `LibHeaderToken` class. You can safely use that token as the provider in the component definition, allowing Angular to correctly inject the concrete type.
|
|
||||||
|
|
||||||
To summarize, the lightweight injection token pattern consists of the following.
|
|
||||||
|
|
||||||
1. A lightweight injection token that is represented as an abstract class.
|
|
||||||
2. A component definition that implements the abstract class.
|
|
||||||
3. Injection of the lightweight pattern, using ` @ContentChild()` or `@ContentChildren()`.
|
|
||||||
4. A provider in the implementation of the lightweight injection token which associates the lightweight injection token with the implementation.
|
|
||||||
|
|
||||||
### Use the lightweight injection token for API definition
|
|
||||||
|
|
||||||
A component that injects a lightweight injection token might need to invoke a method in the injected class.
|
|
||||||
Because the token is now an abstract class, and the injectable component implements that class, you must also declare an abstract method in the abstract lightweight injection token class.
|
|
||||||
The implementation of the method (with all of its code overhead) resides in the injectable component that can be tree-shaken.
|
|
||||||
This allows the parent to communicate with the child (if it is present) in a type-safe manner.
|
|
||||||
|
|
||||||
For example, the `LibCardComponent` now queries`LibHeaderToken` rather than `LibHeaderComponent`.
|
|
||||||
The following example shows how the pattern allows `LibCardComponent` to communicate with the `LibHeaderComponent` without actually referring to `LibHeaderComponent`.
|
|
||||||
|
|
||||||
```
|
|
||||||
abstract class LibHeaderToken {
|
|
||||||
abstract doSomething(): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'lib-header',
|
|
||||||
providers: [
|
|
||||||
{provide: LibHeaderToken, useExisting: LibHeader}
|
|
||||||
]
|
|
||||||
...,
|
|
||||||
})
|
|
||||||
class LibHeaderComponent extends LibHeaderToken {
|
|
||||||
doSomething(): void {
|
|
||||||
// Concrete implementation of `doSomething`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'lib-card',
|
|
||||||
...,
|
|
||||||
})
|
|
||||||
class LibCardComponent implement AfterContentInit {
|
|
||||||
@ContentChild(LibHeaderToken)
|
|
||||||
header: LibHeaderToken|null = null;
|
|
||||||
|
|
||||||
ngAfterContentInit(): void {
|
|
||||||
this.header && this.header.doSomething();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example the parent queries the token to obtain the child component, and stores the resulting component reference if it is present.
|
|
||||||
Before calling a method in the child, the parent component checks to see if the child component is present.
|
|
||||||
If the child component has been tree-shaken, there is no runtime reference to it, and no call to its method.
|
|
||||||
|
|
||||||
### Naming your lightweight injection token
|
|
||||||
|
|
||||||
Lightweight injection tokens are only useful with components. The Angular style guide suggests that you name components using the "Component" suffix. The example "LibHeaderComponent" follows this convention.
|
|
||||||
|
|
||||||
To maintain the relationship between the component and its token while still distinguishing between them, the recommended style is to use the component base name with the suffix "Token" to name your lightweight injection tokens: "LibHeaderToken".
|
|
@ -1,116 +1,41 @@
|
|||||||
# Types of feature modules
|
# Guidelines for creating NgModules
|
||||||
|
|
||||||
There are five general categories of feature modules which
|
This topic provides a conceptual overview of the different categories of [NgModules](guide/glossary#ngmodule "Definition of NgModule") you can create in order to organize your code in a modular structure.
|
||||||
tend to fall into the following groups:
|
These categories are not cast in stone—they are suggestions.
|
||||||
|
You may want to create NgModules for other purposes, or combine the characteristics of some of these categories.
|
||||||
|
|
||||||
* Domain feature modules.
|
NgModules are a great way to organize an app and keep code related to a specific functionality or feature separate from other code.
|
||||||
* Routed feature modules.
|
Use NgModules to consolidate [components](guide/glossary#component "Definition of component"), [directives](guide/glossary#directive "Definition of directive"), and [pipes](guide/glossary#pipe "Definition of pipe)") into cohesive blocks of functionality.
|
||||||
* Routing modules.
|
Focus each block on a feature or business domain, a workflow or navigation flow, a common collection of utilities, or one or more [providers](guide/glossary#provider "Definition of provider") for [services](guide/glossary#service "Definition of service").
|
||||||
* Service feature modules.
|
|
||||||
* Widget feature modules.
|
|
||||||
|
|
||||||
While the following guidelines describe the use of each type and their
|
For more about NgModules, see [Organizing your app with NgModules](guide/ngmodules "Organizing your app with NgModules").
|
||||||
typical characteristics, in real world apps, you may see hybrids.
|
|
||||||
|
|
||||||
<table>
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
<tr>
|
For the example app used in NgModules-related topics, see the <live-example name="ngmodules"></live-example>.
|
||||||
<th style="vertical-align: top">
|
|
||||||
Feature Module
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th style="vertical-align: top">
|
</div>
|
||||||
Guidelines
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
## Summary of NgModule categories
|
||||||
<td>Domain</td>
|
|
||||||
<td>
|
|
||||||
Domain feature modules deliver a user experience dedicated to a particular application domain like editing a customer or placing an order.
|
|
||||||
|
|
||||||
They typically have a top component that acts as the feature root and private, supporting sub-components descend from it.
|
All apps start by [bootstrapping a root NgModule](guide/bootstrapping "Launching an app with a root NgModule").
|
||||||
|
You can organize your other NgModules any way you wish.
|
||||||
|
|
||||||
Domain feature modules consist mostly of declarations. Only the top component is exported.
|
This topic provides some guidelines for the following general categories of NgModules:
|
||||||
|
|
||||||
Domain feature modules rarely have providers. When they do, the lifetime of the provided services should be the same as the lifetime of the module.
|
* [Domain](#domain): A domain NgModule is organized around a feature, business domain, or user experience.
|
||||||
|
* [Routed](#routed): The top component of the NgModule acts as the destination of a [router](guide/glossary#router "Definition of router") navigation route.
|
||||||
|
* [Routing](#routing): A routing NgModule provides the routing configuration for another NgModule.
|
||||||
|
* [Service](#service): A service NgModule provides utility services such as data access and messaging.
|
||||||
|
* [Widget](#widget): A widget NgModule makes a component, directive, or pipe available to other NgModules.
|
||||||
|
* [Shared](#shared): A shared NgModule makes a set of components, directives, and pipes available to other NgModules.
|
||||||
|
|
||||||
Domain feature modules are typically imported exactly once by a larger feature module.
|
The following table summarizes the key characteristics of each category.
|
||||||
|
|
||||||
They might be imported by the root `AppModule` of a small application that lacks routing.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Routed</td>
|
|
||||||
<td>
|
|
||||||
Routed feature modules are domain feature modules whose top components are the targets of router navigation routes.
|
|
||||||
|
|
||||||
All lazy-loaded modules are routed feature modules by definition.
|
|
||||||
|
|
||||||
Routed feature modules don’t export anything because their components never appear in the template of an external component.
|
|
||||||
|
|
||||||
A lazy-loaded routed feature module should not be imported by any module. Doing so would trigger an eager load, defeating the purpose of lazy loading.That means you won’t see them mentioned among the `AppModule` imports. An eager loaded routed feature module must be imported by another module so that the compiler learns about its components.
|
|
||||||
|
|
||||||
Routed feature modules rarely have providers for reasons explained in [Lazy Loading Feature Modules](/guide/lazy-loading-ngmodules). When they do, the lifetime of the provided services should be the same as the lifetime of the module. Don't provide application-wide singleton services in a routed feature module or in a module that the routed module imports.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>Routing</td>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
A routing module provides routing configuration for another module and separates routing concerns from its companion module.
|
|
||||||
|
|
||||||
A routing module typically does the following:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Defines routes.</li>
|
|
||||||
<li>Adds router configuration to the module's imports.</li>
|
|
||||||
<li>Adds guard and resolver service providers to the module's providers.</li>
|
|
||||||
<li>The name of the routing module should parallel the name of its companion module, using the suffix "Routing". For example, <code>FooModule</code> in <code>foo.module.ts</code> has a routing module named <code>FooRoutingModule</code> in <code>foo-routing.module.ts</code>. If the companion module is the root <code>AppModule</code>, the <code>AppRoutingModule</code> adds router configuration to its imports with <code>RouterModule.forRoot(routes)</code>. All other routing modules are children that import <code>RouterModule.forChild(routes)</code>.</li>
|
|
||||||
<li>A routing module re-exports the <code>RouterModule</code> as a convenience so that components of the companion module have access to router directives such as <code>RouterLink</code> and <code>RouterOutlet</code>.</li>
|
|
||||||
<li>A routing module does not have its own declarations. Components, directives, and pipes are the responsibility of the feature module, not the routing module.</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
A routing module should only be imported by its companion module.
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>Service</td>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
Service modules provide utility services such as data access and messaging. Ideally, they consist entirely of providers and have no declarations. Angular's `HttpClientModule` is a good example of a service module.
|
|
||||||
|
|
||||||
The root `AppModule` is the only module that should import service modules.
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>Widget</td>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
A widget module makes components, directives, and pipes available to external modules. Many third-party UI component libraries are widget modules.
|
|
||||||
|
|
||||||
A widget module should consist entirely of declarations, most of them exported.
|
|
||||||
|
|
||||||
A widget module should rarely have providers.
|
|
||||||
|
|
||||||
Import widget modules in any module whose component templates need the widgets.
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
|
|
||||||
The following table summarizes the key characteristics of each feature module group.
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="vertical-align: top">
|
<th style="vertical-align: top">
|
||||||
Feature Module
|
NgModule
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<th style="vertical-align: top">
|
<th style="vertical-align: top">
|
||||||
@ -135,7 +60,7 @@ The following table summarizes the key characteristics of each feature module gr
|
|||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
<td>Rare</td>
|
<td>Rare</td>
|
||||||
<td>Top component</td>
|
<td>Top component</td>
|
||||||
<td>Feature, AppModule</td>
|
<td>Another domain, AppModule</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@ -151,7 +76,7 @@ The following table summarizes the key characteristics of each feature module gr
|
|||||||
<td>No</td>
|
<td>No</td>
|
||||||
<td>Yes (Guards)</td>
|
<td>Yes (Guards)</td>
|
||||||
<td>RouterModule</td>
|
<td>RouterModule</td>
|
||||||
<td>Feature (for routing)</td>
|
<td>Another domain (for routing)</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
@ -167,14 +92,137 @@ The following table summarizes the key characteristics of each feature module gr
|
|||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
<td>Rare</td>
|
<td>Rare</td>
|
||||||
<td>Yes</td>
|
<td>Yes</td>
|
||||||
<td>Feature</td>
|
<td>Another domain</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Shared</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>No</td>
|
||||||
|
<td>Yes</td>
|
||||||
|
<td>Another domain</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<hr />
|
{@a domain}
|
||||||
|
|
||||||
## More on NgModules
|
## Domain NgModules
|
||||||
|
|
||||||
|
Use a domain NgModule to deliver a user experience dedicated to a particular feature or app domain, such as editing a customer or placing an order.
|
||||||
|
One example is `ContactModule` in the <live-example name="ngmodules"></live-example>.
|
||||||
|
|
||||||
|
A domain NgModule organizes the code related to a certain function, containing all of the components, routing, and templates that make up the function.
|
||||||
|
Your top component in the domain NgModule acts as the feature or domain's root, and is the only component you export.
|
||||||
|
Private supporting subcomponents descend from it.
|
||||||
|
|
||||||
|
Import a domain NgModule exactly once into another NgModule, such as a domain NgModule, or into the root NgModule (`AppModule`) of an app that contains only a few NgModules.
|
||||||
|
|
||||||
|
Domain NgModules consist mostly of declarations.
|
||||||
|
You rarely include providers.
|
||||||
|
If you do, the lifetime of the provided services should be the same as the lifetime of the NgModule.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
For more information about lifecycles, see [Hooking into the component lifecycle](guide/lifecycle-hooks "Hooking into the component lifecycle").
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a routed}
|
||||||
|
|
||||||
|
## Routed NgModules
|
||||||
|
|
||||||
|
Use a routed NgModule for all [lazy-loaded NgModules](guide/lazy-loading-ngmodules "Lazy-loading an NgModule").
|
||||||
|
Use the top component of the NgModule as the destination of a router navigation route.
|
||||||
|
Routed NgModules don’t export anything because their components never appear in the template of an external component.
|
||||||
|
|
||||||
|
Don't import a lazy-loaded routed NgModule into another NgModule, as this would trigger an eager load, defeating the purpose of lazy loading.
|
||||||
|
|
||||||
|
Routed NgModules rarely have providers because you load a routed NgModule only when needed (such as for routing).
|
||||||
|
Services listed in the NgModules' `provider` array would not be available because the root injector wouldn’t know about the lazy-loaded NgModule.
|
||||||
|
If you include providers, the lifetime of the provided services should be the same as the lifetime of the NgModule.
|
||||||
|
Don't provide app-wide [singleton services](guide/singleton-services) in a routed NgModule or in an NgModule that the routed NgModule imports.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
For more information about providers and lazy-loaded routed NgModules, see [Limiting provider scope](guide/providers#limiting-provider-scope-by-lazy-loading-modules "Providing dependencies: Limiting provider scope").
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a routing}
|
||||||
|
|
||||||
|
## Routing NgModules
|
||||||
|
|
||||||
|
Use a routing NgModule to provide the routing configuration for a domain NgModule, thereby separating routing concerns from its companion domain NgModule.
|
||||||
|
One example is `ContactRoutingModule` in the <live-example name="ngmodules"></live-example>, which provides the routing for its companion domain NgModule `ContactModule`.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
For an overview and details about routing, see [In-app navigation: routing to views](guide/router "In-app navigation: routing to views").
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Use a routing NgModule to do the following tasks:
|
||||||
|
|
||||||
|
* Define routes.
|
||||||
|
* Add router configuration to the NgModule's import.
|
||||||
|
* Add guard and resolver service providers to the NgModule's providers.
|
||||||
|
|
||||||
|
The name of the routing NgModule should parallel the name of its companion NgModule, using the suffix `Routing`.
|
||||||
|
For example, <code>ContactModule</code> in <code>contact.module.ts</code> has a routing NgModule named <code>ContactRoutingModule</code> in <code>contact-routing.module.ts</code>.
|
||||||
|
|
||||||
|
Import a routing NgModule only into its companion NgModule.
|
||||||
|
If the companion NgModule is the root <code>AppModule</code>, the <code>AppRoutingModule</code> adds router configuration to its imports with <code>RouterModule.forRoot(routes)</code>.
|
||||||
|
All other routing NgModules are children that import <code>RouterModule.forChild(routes)</code>.
|
||||||
|
|
||||||
|
In your routing NgModule, re-export the <code>RouterModule</code> as a convenience so that components of the companion NgModule have access to router directives such as <code>RouterLink</code> and <code>RouterOutlet</code>.
|
||||||
|
|
||||||
|
Don't use declarations in a routing NgModule.
|
||||||
|
Components, directives, and pipes are the responsibility of the companion domain NgModule, not the routing NgModule.
|
||||||
|
|
||||||
|
{@a service}
|
||||||
|
|
||||||
|
## Service NgModules
|
||||||
|
|
||||||
|
Use a service NgModule to provide a utility service such as data access or messaging.
|
||||||
|
Ideal service NgModules consist entirely of providers and have no declarations.
|
||||||
|
Angular's `HttpClientModule` is a good example of a service NgModule.
|
||||||
|
|
||||||
|
Use only the root `AppModule` to import service NgModules.
|
||||||
|
|
||||||
|
{@a widget}
|
||||||
|
|
||||||
|
## Widget NgModules
|
||||||
|
|
||||||
|
Use a widget NgModule to make a component, directive, or pipe available to external NgModules.
|
||||||
|
Import widget NgModules into any NgModules that need the widgets in their templates.
|
||||||
|
Many third-party UI component libraries are provided as widget NgModules.
|
||||||
|
|
||||||
|
A widget NgModule should consist entirely of declarations, most of them exported.
|
||||||
|
It would rarely have providers.
|
||||||
|
|
||||||
|
{@a shared}
|
||||||
|
|
||||||
|
## Shared NgModules
|
||||||
|
|
||||||
|
Put commonly used directives, pipes, and components into one NgModule, typically named `SharedModule`, and then import just that NgModule wherever you need it in other parts of your app.
|
||||||
|
You can import the shared NgModule in your domain NgModules, including [lazy-loaded NgModules](guide/lazy-loading-ngmodules "Lazy-loading an NgModule").
|
||||||
|
One example is `SharedModule` in the <live-example name="ngmodules"></live-example>, which provides the `AwesomePipe` custom pipe and `HighlightDirective` directive.
|
||||||
|
|
||||||
|
Shared NgModules should not include providers, nor should any of its imported or re-exported NgModules include providers.
|
||||||
|
|
||||||
|
To learn how to use shared modules to organize and streamline your code, see [Sharing NgModules in an app](guide/sharing-ngmodules "Sharing NgModules in an app").
|
||||||
|
|
||||||
|
## Next steps
|
||||||
|
|
||||||
You may also be interested in the following:
|
You may also be interested in the following:
|
||||||
* [Lazy Loading Modules with the Angular Router](guide/lazy-loading-ngmodules).
|
|
||||||
* [Providers](guide/providers).
|
* For more about NgModules, see [Organizing your app with NgModules](guide/ngmodules "Organizing your app with NgModules").
|
||||||
|
* To learn more about the root NgModule, see [Launching an app with a root NgModule](guide/bootstrapping "Launching an app with a root NgModule").
|
||||||
|
* To learn about frequently used Angular NgModules and how to import them into your app, see [Frequently-used modules](guide/frequent-ngmodules "Frequently-used modules").
|
||||||
|
* For a complete description of the NgModule metadata properties, see [Using the NgModule metadata](guide/ngmodule-api "Using the NgModule metadata").
|
||||||
|
|
||||||
|
If you want to manage NgModule loading and the use of dependencies and services, see the following:
|
||||||
|
|
||||||
|
* To learn about loading NgModules eagerly when the app starts, or lazy-loading NgModules asynchronously by the router, see [Lazy-loading feature modules](guide/lazy-loading-ngmodules).
|
||||||
|
* To understand how to provide a service or other dependency for your app, see [Providing Dependencies for an NgModule](guide/providers "Providing Dependencies for an NgModule").
|
||||||
|
* To learn how to create a singleton service to use in NgModules, see [Making a service a singleton](guide/singleton-services "Making a service a singleton").
|
||||||
|
@ -1,72 +1,82 @@
|
|||||||
# JavaScript modules vs. NgModules
|
# JavaScript modules vs. NgModules
|
||||||
|
|
||||||
JavaScript and Angular use modules to organize code, and
|
JavaScript modules and NgModules can help you modularize your code, but they are very different.
|
||||||
though they organize it differently, Angular apps rely on both.
|
Angular apps rely on both kinds of modules.
|
||||||
|
|
||||||
|
## JavaScript modules: Files containing code
|
||||||
|
|
||||||
## JavaScript modules
|
A [JavaScript module](https://javascript.info/modules "JavaScript.Info - Modules") is an individual file with JavaScript code, usually containing a class or a library of functions for a specific purpose within your app.
|
||||||
|
JavaScript modules let you spread your work across multiple files.
|
||||||
|
|
||||||
In JavaScript, modules are individual files with JavaScript code in them. To make what’s in them available, you write an export statement, usually after the relevant code, like this:
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
To learn more about JavaScript modules, see [ES6 In Depth: Modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/).
|
||||||
|
For the module specification, see the [6th Edition of the ECMAScript standard](http://www.ecma-international.org/ecma-262/6.0/#sec-modules).
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
To make the code in a JavaScript module available to other modules, use an `export` statement at the end of the relevant code in the module, such as the following:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
export class AppComponent { ... }
|
export class AppComponent { ... }
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, when you need that file’s code in another file, you import it like this:
|
When you need that module’s code in another module, use an `import` statement as follows:
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
```
|
```
|
||||||
|
|
||||||
JavaScript modules help you namespace, preventing accidental global variables.
|
Each module has its own top-level scope.
|
||||||
|
In other words, top-level variables and functions in a module are not seen in other scripts or modules.
|
||||||
|
Each module provides a namespace for identifiers to prevent them from clashing with identifiers in other modules.
|
||||||
|
With multiple modules, you can prevent accidental global variables by creating a single global namespace and adding sub-modules to it.
|
||||||
|
|
||||||
For more information on JavaScript modules, see [JavaScript/ECMAScript modules](https://hacks.mozilla.org/2015/08/es6-in-depth-modules/).
|
The Angular framework itself is loaded as a set of JavaScript modules.
|
||||||
|
|
||||||
## NgModules
|
## NgModules: Classes with metadata for compiling
|
||||||
|
|
||||||
<!-- KW-- perMisko: let's discuss. This does not answer the question why it is different. Also, last sentence is confusing.-->
|
An [NgModule](guide/glossary#ngmodule "Definition of NgModule") is a class marked by the `@NgModule` decorator with a metadata object that describes how that particular part of the app fits together with the other parts.
|
||||||
NgModules are classes decorated with `@NgModule`. The `@NgModule` decorator’s `imports` array tells Angular what other NgModules the current module needs. The modules in the `imports` array are different than JavaScript modules because they are NgModules rather than regular JavaScript modules. Classes with an `@NgModule` decorator are by convention kept in their own files, but what makes them an `NgModule` isn’t being in their own file, like JavaScript modules; it’s the presence of `@NgModule` and its metadata.
|
NgModules are specific to Angular.
|
||||||
|
While classes with an `@NgModule` decorator are by convention kept in their own files, they differ from JavaScript modules because they include this metadata.
|
||||||
|
|
||||||
The `AppModule` generated from the [Angular CLI](cli) demonstrates both kinds of modules in action:
|
The `@NgModule` metadata plays an important role in guiding the Angular compilation process that converts the app code you write into highly performant JavaScript code.
|
||||||
|
The metadata describes how to compile a component's template and how to create an [injector](guide/glossary#injector "Definition of injector") at runtime.
|
||||||
|
It identifies the NgModule's [components](guide/glossary#component "Definition of component"), [directives](guide/glossary#directive "Definition of directive"), and [pipes](guide/glossary#pipe "Definition of pipe)"),
|
||||||
|
and makes some of them public through the `exports` property so that external components can use them.
|
||||||
|
You can also use an NgModule to add [providers](guide/glossary#provider "Definition of provider") for [services](guide/glossary#service "Definition of a service"), so that the services are available elsewhere in your app.
|
||||||
|
|
||||||
```typescript
|
Rather than defining all member classes in one giant file as a JavaScript module, declare which components, directives, and pipes belong to the NgModule in the `@NgModule.declarations` list.
|
||||||
/* These are JavaScript import statements. Angular doesn’t know anything about these. */
|
These classes are called [declarables](guide/glossary#declarable "Definition of a declarable").
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
An NgModule can export only the declarable classes it owns or imports from other NgModules.
|
||||||
import { NgModule } from '@angular/core';
|
It doesn't declare or export any other kind of class.
|
||||||
|
Declarables are the only classes that matter to the Angular compilation process.
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
For a complete description of the NgModule metadata properties, see [Using the NgModule metadata](guide/ngmodule-api "Using the NgModule metadata").
|
||||||
|
|
||||||
/* The @NgModule decorator lets Angular know that this is an NgModule. */
|
## An example that uses both
|
||||||
@NgModule({
|
|
||||||
declarations: [
|
|
||||||
AppComponent
|
|
||||||
],
|
|
||||||
imports: [ /* These are NgModule imports. */
|
|
||||||
BrowserModule
|
|
||||||
],
|
|
||||||
providers: [],
|
|
||||||
bootstrap: [AppComponent]
|
|
||||||
})
|
|
||||||
export class AppModule { }
|
|
||||||
```
|
|
||||||
|
|
||||||
|
The root NgModule `AppModule` generated by the [Angular CLI](cli) for a new app project demonstrates how you use both kinds of modules:
|
||||||
|
|
||||||
The NgModule classes differ from JavaScript module in the following key ways:
|
<code-example path="ngmodules/src/app/app.module.1.ts" header="src/app/app.module.ts (default AppModule)"></code-example>
|
||||||
|
|
||||||
* An NgModule bounds [declarable classes](guide/ngmodule-faq#q-declarable) only.
|
The root NgModule starts with `import` statements to import JavaScript modules.
|
||||||
Declarables are the only classes that matter to the [Angular compiler](guide/ngmodule-faq#q-angular-compiler).
|
It then configures the `@NgModule` with the following arrays:
|
||||||
* Instead of defining all member classes in one giant file as in a JavaScript module,
|
|
||||||
you list the module's classes in the `@NgModule.declarations` list.
|
|
||||||
* An NgModule can only export the [declarable classes](guide/ngmodule-faq#q-declarable)
|
|
||||||
it owns or imports from other modules. It doesn't declare or export any other kind of class.
|
|
||||||
* Unlike JavaScript modules, an NgModule can extend the _entire_ application with services
|
|
||||||
by adding providers to the `@NgModule.providers` list.
|
|
||||||
|
|
||||||
<hr />
|
* `declarations`: The components, directives, and pipes that belong to the NgModule.
|
||||||
|
A new app project's root NgModule has only one component, called `AppComponent`.
|
||||||
|
|
||||||
## More on NgModules
|
* `imports`: Other NgModules you are using, so that you can use their declarables.
|
||||||
|
The newly generated root NgModule imports [`BrowserModule`](api/platform-browser/BrowserModule "BrowserModule NgModule") in order to use browser-specific services such as [DOM](https://www.w3.org/TR/DOM-Level-2-Core/introduction.html "Definition of Document Object Model") rendering, sanitization, and location.
|
||||||
|
|
||||||
For more information on NgModules, see:
|
* `providers`: Providers of services that components in other NgModules can use.
|
||||||
* [Bootstrapping](guide/bootstrapping).
|
There are no providers in a newly generated root NgModule.
|
||||||
* [Frequently used modules](guide/frequent-ngmodules).
|
|
||||||
* [Providers](guide/providers).
|
* `bootstrap`: The [entry component](guide/entry-components "Specifying an entry component") that Angular creates and inserts into the `index.html` host web page, thereby bootstrapping the app.
|
||||||
|
This entry component, `AppComponent`, appears in both the `declarations` and the `bootstrap` arrays.
|
||||||
|
|
||||||
|
## Next steps
|
||||||
|
|
||||||
|
* For more about NgModules, see [Organizing your app with NgModules](guide/ngmodules "Organizing your app with NgModules").
|
||||||
|
* To learn more about the root NgModule, see [Launching an app with a root NgModule](guide/bootstrapping "Launching an app with a root NgModule").
|
||||||
|
* To learn about frequently used Angular NgModules and how to import them into your app, see [Frequently-used modules](guide/frequent-ngmodules "Frequently-used modules").
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
Angular makes use of observables as an interface to handle a variety of common asynchronous operations. For example:
|
Angular makes use of observables as an interface to handle a variety of common asynchronous operations. For example:
|
||||||
|
|
||||||
* You can define [custom events](guide/template-syntax#custom-events-with-eventemitter) that send observable output data from a child to a parent component.
|
* You can define [custom events](guide/event-binding#custom-events-with-eventemitter) that send observable output data from a child to a parent component.
|
||||||
* The HTTP module uses observables to handle AJAX requests and responses.
|
* The HTTP module uses observables to handle AJAX requests and responses.
|
||||||
* The Router and Forms modules use observables to listen for and respond to user-input events.
|
* The Router and Forms modules use observables to listen for and respond to user-input events.
|
||||||
|
|
||||||
## Transmitting data between components
|
## Transmitting data between components
|
||||||
|
|
||||||
Angular provides an `EventEmitter` class that is used when publishing values from a component through the [`@Output()` decorator](guide/template-syntax#how-to-use-output).
|
Angular provides an `EventEmitter` class that is used when publishing values from a component through the [`@Output()` decorator](guide/inputs-outputs#how-to-use-output).
|
||||||
`EventEmitter` extends [RxJS `Subject`](https://rxjs.dev/api/index/class/Subject), adding an `emit()` method so it can send arbitrary values.
|
`EventEmitter` extends [RxJS `Subject`](https://rxjs.dev/api/index/class/Subject), adding an `emit()` method so it can send arbitrary values.
|
||||||
When you call `emit()`, it passes the emitted value to the `next()` method of any subscribed observer.
|
When you call `emit()`, it passes the emitted value to the `next()` method of any subscribed observer.
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Transforming Data Using Pipes
|
# Transforming Data Using Pipes
|
||||||
|
|
||||||
Use [pipes](guide/glossary#pipe "Definition of a pipe") to transform and format strings, currency amounts, dates, and other display data.
|
Use [pipes](guide/glossary#pipe "Definition of a pipe") to transform strings, currency amounts, dates, and other data for display.
|
||||||
Pipes are simple functions you can use in [template expressions](/guide/glossary#template-expression "Definition of template expression") to accept an input value and return a transformed value.
|
Pipes are simple functions you can use in [template expressions](/guide/glossary#template-expression "Definition of template expression") to accept an input value and return a transformed value. Pipes are useful because you can use them throughout your application, while only declaring each pipe once.
|
||||||
For example, you would use a pipe to show a date as **April 15, 1988** rather than the raw string format.
|
For example, you would use a pipe to show a date as **April 15, 1988** rather than the raw string format.
|
||||||
|
|
||||||
<div class="alert is-helpful">
|
<div class="alert is-helpful">
|
||||||
@ -58,12 +58,12 @@ The tabs in the example show the following:
|
|||||||
</code-tabs>
|
</code-tabs>
|
||||||
|
|
||||||
The component's `birthday` value flows through the
|
The component's `birthday` value flows through the
|
||||||
[pipe operator](guide/template-syntax#pipe) ( | ) to the [`date`](api/common/DatePipe)
|
[pipe operator](guide/template-expression-operators#pipe) ( | ) to the [`date`](api/common/DatePipe)
|
||||||
function.
|
function.
|
||||||
|
|
||||||
{@a parameterizing-a-pipe}
|
{@a parameterizing-a-pipe}
|
||||||
|
|
||||||
## Formatting data with parameters and chained pipes
|
## Transforming data with parameters and chained pipes
|
||||||
|
|
||||||
Use optional parameters to fine-tune a pipe's output.
|
Use optional parameters to fine-tune a pipe's output.
|
||||||
For example, you can use the [`CurrencyPipe`](api/common/CurrencyPipe "API reference") with a country code such as EUR as a parameter.
|
For example, you can use the [`CurrencyPipe`](api/common/CurrencyPipe "API reference") with a country code such as EUR as a parameter.
|
||||||
|
228
aio/content/guide/property-binding.md
Normal file
228
aio/content/guide/property-binding.md
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
|
||||||
|
# Property binding `[property]`
|
||||||
|
|
||||||
|
Use property binding to _set_ properties of target elements or
|
||||||
|
directive `@Input()` decorators.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## One-way in
|
||||||
|
|
||||||
|
Property binding flows a value in one direction,
|
||||||
|
from a component's property into a target element property.
|
||||||
|
|
||||||
|
You can't use property
|
||||||
|
binding to read or pull values out of target elements. Similarly, you cannot use
|
||||||
|
property binding to call a method on the target element.
|
||||||
|
If the element raises events, you can listen to them with an [event binding](guide/event-binding).
|
||||||
|
|
||||||
|
If you must read a target element property or call one of its methods,
|
||||||
|
see the API reference for [ViewChild](api/core/ViewChild) and
|
||||||
|
[ContentChild](api/core/ContentChild).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
The most common property binding sets an element property to a component
|
||||||
|
property value. An example is
|
||||||
|
binding the `src` property of an image element to a component's `itemImageUrl` property:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="property-binding" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Here's an example of binding to the `colSpan` property. Notice that it's not `colspan`,
|
||||||
|
which is the attribute, spelled with a lowercase `s`.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="colSpan" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
For more details, see the [MDN HTMLTableCellElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableCellElement) documentation.
|
||||||
|
|
||||||
|
For more information about `colSpan` and `colspan`, see the [Attribute binding](guide/attribute-binding#colspan) guide.
|
||||||
|
|
||||||
|
Another example is disabling a button when the component says that it `isUnchanged`:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="disabled-button" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Another is setting a property of a directive:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="class-binding" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Yet another is setting the model property of a custom component—a great way
|
||||||
|
for parent and child components to communicate:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="model-property-binding" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
## Binding targets
|
||||||
|
|
||||||
|
An element property between enclosing square brackets identifies the target property.
|
||||||
|
The target property in the following code is the image element's `src` property.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="property-binding" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
There's also the `bind-` prefix alternative:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="bind-prefix" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
In most cases, the target name is the name of a property, even
|
||||||
|
when it appears to be the name of an attribute.
|
||||||
|
So in this case, `src` is the name of the `<img>` element property.
|
||||||
|
|
||||||
|
Element properties may be the more common targets,
|
||||||
|
but Angular looks first to see if the name is a property of a known directive,
|
||||||
|
as it is in the following example:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="class-binding" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Technically, Angular is matching the name to a directive `@Input()`,
|
||||||
|
one of the property names listed in the directive's `inputs` array
|
||||||
|
or a property decorated with `@Input()`.
|
||||||
|
Such inputs map to the directive's own properties.
|
||||||
|
|
||||||
|
If the name fails to match a property of a known directive or element, Angular reports an “unknown directive” error.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
Though the target name is usually the name of a property,
|
||||||
|
there is an automatic attribute-to-property mapping in Angular for
|
||||||
|
several common attributes. These include `class`/`className`, `innerHtml`/`innerHTML`, and
|
||||||
|
`tabindex`/`tabIndex`.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
## Avoid side effects
|
||||||
|
|
||||||
|
Evaluation of a template expression should have no visible side effects.
|
||||||
|
The expression language itself, or the way you write template expressions,
|
||||||
|
helps to a certain extent;
|
||||||
|
you can't assign a value to anything in a property binding expression
|
||||||
|
nor use the increment and decrement operators.
|
||||||
|
|
||||||
|
For example, you could have an expression that invoked a property or method that had
|
||||||
|
side effects. The expression could call something like `getFoo()` where only you
|
||||||
|
know what `getFoo()` does. If `getFoo()` changes something
|
||||||
|
and you happen to be binding to that something,
|
||||||
|
Angular may or may not display the changed value. Angular may detect the
|
||||||
|
change and throw a warning error.
|
||||||
|
As a best practice, stick to properties and to methods that return
|
||||||
|
values and avoid side effects.
|
||||||
|
|
||||||
|
## Return the proper type
|
||||||
|
|
||||||
|
The template expression should evaluate to the type of value
|
||||||
|
that the target property expects.
|
||||||
|
Return a string if the target property expects a string, a number if it
|
||||||
|
expects a number, an object if it expects an object, and so on.
|
||||||
|
|
||||||
|
In the following example, the `childItem` property of the `ItemDetailComponent` expects a string, which is exactly what you're sending in the property binding:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="model-property-binding" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
You can confirm this by looking in the `ItemDetailComponent` where the `@Input` type is set to a string:
|
||||||
|
<code-example path="property-binding/src/app/item-detail/item-detail.component.ts" region="input-type" header="src/app/item-detail/item-detail.component.ts (setting the @Input() type)"></code-example>
|
||||||
|
|
||||||
|
As you can see here, the `parentItem` in `AppComponent` is a string, which the `ItemDetailComponent` expects:
|
||||||
|
<code-example path="property-binding/src/app/app.component.ts" region="parent-data-type" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
### Passing in an object
|
||||||
|
|
||||||
|
The previous simple example showed passing in a string. To pass in an object,
|
||||||
|
the syntax and thinking are the same.
|
||||||
|
|
||||||
|
In this scenario, `ItemListComponent` is nested within `AppComponent` and the `items` property expects an array of objects.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="pass-object" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The `items` property is declared in the `ItemListComponent` with a type of `Item` and decorated with `@Input()`:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/item-list/item-list.component.ts" region="item-input" header="src/app/item-list.component.ts"></code-example>
|
||||||
|
|
||||||
|
In this sample app, an `Item` is an object that has two properties; an `id` and a `name`.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/item.ts" region="item-class" header="src/app/item.ts"></code-example>
|
||||||
|
|
||||||
|
While a list of items exists in another file, `mock-items.ts`, you can
|
||||||
|
specify a different item in `app.component.ts` so that the new item will render:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.ts" region="pass-object" header="src/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
You just have to make sure, in this case, that you're supplying an array of objects because that's the type of `Item` and is what the nested component, `ItemListComponent`, expects.
|
||||||
|
|
||||||
|
In this example, `AppComponent` specifies a different `item` object
|
||||||
|
(`currentItems`) and passes it to the nested `ItemListComponent`. `ItemListComponent` was able to use `currentItems` because it matches what an `Item` object is according to `item.ts`. The `item.ts` file is where
|
||||||
|
`ItemListComponent` gets its definition of an `item`.
|
||||||
|
|
||||||
|
## Remember the brackets
|
||||||
|
|
||||||
|
The brackets, `[]`, tell Angular to evaluate the template expression.
|
||||||
|
If you omit the brackets, Angular treats the string as a constant
|
||||||
|
and *initializes the target property* with that string:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="no-evaluation" header="src/app.component.html"></code-example>
|
||||||
|
|
||||||
|
|
||||||
|
Omitting the brackets will render the string
|
||||||
|
`parentItem`, not the value of `parentItem`.
|
||||||
|
|
||||||
|
## One-time string initialization
|
||||||
|
|
||||||
|
You *should* omit the brackets when all of the following are true:
|
||||||
|
|
||||||
|
* The target property accepts a string value.
|
||||||
|
* The string is a fixed value that you can put directly into the template.
|
||||||
|
* This initial value never changes.
|
||||||
|
|
||||||
|
You routinely initialize attributes this way in standard HTML, and it works
|
||||||
|
just as well for directive and component property initialization.
|
||||||
|
The following example initializes the `prefix` property of the `StringInitComponent` to a fixed string,
|
||||||
|
not a template expression. Angular sets it and forgets about it.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="string-init" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The `[item]` binding, on the other hand, remains a live binding to the component's `currentItems` property.
|
||||||
|
|
||||||
|
## Property binding vs. interpolation
|
||||||
|
|
||||||
|
You often have a choice between interpolation and property binding.
|
||||||
|
The following binding pairs do the same thing:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="property-binding-interpolation" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Interpolation is a convenient alternative to property binding in
|
||||||
|
many cases. When rendering data values as strings, there is no
|
||||||
|
technical reason to prefer one form to the other, though readability
|
||||||
|
tends to favor interpolation. However, *when setting an element
|
||||||
|
property to a non-string data value, you must use property binding*.
|
||||||
|
|
||||||
|
## Content security
|
||||||
|
|
||||||
|
Imagine the following malicious content.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.ts" region="malicious-content" header="src/app/app.component.ts"></code-example>
|
||||||
|
|
||||||
|
In the component template, the content might be used with interpolation:
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="malicious-interpolated" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Fortunately, Angular data binding is on alert for dangerous HTML. In the above case,
|
||||||
|
the HTML displays as is, and the Javascript does not execute. Angular **does not**
|
||||||
|
allow HTML with script tags to leak into the browser, neither with interpolation
|
||||||
|
nor property binding.
|
||||||
|
|
||||||
|
In the following example, however, Angular [sanitizes](guide/security#sanitization-and-security-contexts)
|
||||||
|
the values before displaying them.
|
||||||
|
|
||||||
|
<code-example path="property-binding/src/app/app.component.html" region="malicious-content" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Interpolation handles the `<script>` tags differently than
|
||||||
|
property binding but both approaches render the
|
||||||
|
content harmlessly. The following is the browser output
|
||||||
|
of the `evilTitle` examples.
|
||||||
|
|
||||||
|
<code-example language="bash">
|
||||||
|
"Template <script>alert("evil never sleeps")</script> Syntax" is the interpolated evil title.
|
||||||
|
"Template alert("evil never sleeps")Syntax" is the property bound evil title.
|
||||||
|
</code-example>
|
@ -1170,7 +1170,7 @@ The `ActivatedRoute.paramMap` property is an `Observable` map of route parameter
|
|||||||
The `paramMap` emits a new map of values that includes `id` when the user navigates to the component.
|
The `paramMap` emits a new map of values that includes `id` when the user navigates to the component.
|
||||||
In `ngOnInit()` you subscribe to those values, set the `selectedId`, and get the heroes.
|
In `ngOnInit()` you subscribe to those values, set the `selectedId`, and get the heroes.
|
||||||
|
|
||||||
Update the template with a [class binding](guide/template-syntax#class-binding).
|
Update the template with a [class binding](guide/attribute-binding#class-binding).
|
||||||
The binding adds the `selected` CSS class when the comparison returns `true` and removes it when `false`.
|
The binding adds the `selected` CSS class when the comparison returns `true` and removes it when `false`.
|
||||||
Look for it within the repeated `<li>` tag as shown here:
|
Look for it within the repeated `<li>` tag as shown here:
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ This tutorial describes how you can build a single-page application, SPA that us
|
|||||||
|
|
||||||
|
|
||||||
In an SPA, all of your application's functions exist in a single HTML page.
|
In an SPA, all of your application's functions exist in a single HTML page.
|
||||||
As users access your application's features, the browser needs to render only the parts that matter to the user, instead of loading a new page. This pattern can significantly improve your application's user exprience.
|
As users access your application's features, the browser needs to render only the parts that matter to the user, instead of loading a new page. This pattern can significantly improve your application's user experience.
|
||||||
|
|
||||||
To define how users navigate through your application, you use routes. You can add routes to define how users navigate from one part of your application to another.
|
To define how users navigate through your application, you use routes. You can add routes to define how users navigate from one part of your application to another.
|
||||||
You can also configure routes to guard against unexpected or unauthorized behavior.
|
You can also configure routes to guard against unexpected or unauthorized behavior.
|
||||||
@ -105,7 +105,7 @@ In this section, you'll define two routes:
|
|||||||
* The route `/crisis-center` opens the `crisis-center` component.
|
* The route `/crisis-center` opens the `crisis-center` component.
|
||||||
* The route `/heroes-list` opens the `heroes-list` component.
|
* The route `/heroes-list` opens the `heroes-list` component.
|
||||||
|
|
||||||
A route definition is a JavaScript object. Each route typically has two propteries. The first property, `path`, is a string
|
A route definition is a JavaScript object. Each route typically has two properties. The first property, `path`, is a string
|
||||||
that specifies the URL path for the route. The second property, `component`, is a string that specifies
|
that specifies the URL path for the route. The second property, `component`, is a string that specifies
|
||||||
what component your application should display for that path.
|
what component your application should display for that path.
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ Now when you open your application, it displays the `heroes-list` component by d
|
|||||||
## Adding a 404 page
|
## Adding a 404 page
|
||||||
|
|
||||||
It is possible for a user to try to access a route that you have not defined. To account for
|
It is possible for a user to try to access a route that you have not defined. To account for
|
||||||
this behavior, a best practice is to display a 404 page. In this section, you'll create a 404 page and
|
this behavior, the best practice is to display a 404 page. In this section, you'll create a 404 page and
|
||||||
update your route configuration to show that page for any unspecified routes.
|
update your route configuration to show that page for any unspecified routes.
|
||||||
|
|
||||||
1. From the terminal, create a new component, `PageNotFound`.
|
1. From the terminal, create a new component, `PageNotFound`.
|
||||||
|
@ -541,6 +541,15 @@ set the `href` value in `index.html` as shown here.
|
|||||||
|
|
||||||
### HTML5 URLs and the `<base href>`
|
### HTML5 URLs and the `<base href>`
|
||||||
|
|
||||||
|
The guidelines that follow will refer to different parts of a URL. This diagram outlines what those parts refer to:
|
||||||
|
|
||||||
|
```
|
||||||
|
foo://example.com:8042/over/there?name=ferret#nose
|
||||||
|
\_/ \______________/\_________/ \_________/ \__/
|
||||||
|
| | | | |
|
||||||
|
scheme authority path query fragment
|
||||||
|
```
|
||||||
|
|
||||||
While the router uses the <a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries" title="Browser history push-state">HTML5 pushState</a> style by default, you must configure that strategy with a `<base href>`.
|
While the router uses the <a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries" title="Browser history push-state">HTML5 pushState</a> style by default, you must configure that strategy with a `<base href>`.
|
||||||
|
|
||||||
The preferred way to configure the strategy is to add a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base" title="base href"><base href> element</a> tag in the `<head>` of the `index.html`.
|
The preferred way to configure the strategy is to add a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base" title="base href"><base href> element</a> tag in the `<head>` of the `index.html`.
|
||||||
@ -554,8 +563,16 @@ Some developers may not be able to add the `<base>` element, perhaps because the
|
|||||||
|
|
||||||
Those developers may still use HTML5 URLs by taking the following two steps:
|
Those developers may still use HTML5 URLs by taking the following two steps:
|
||||||
|
|
||||||
1. Provide the router with an appropriate [APP_BASE_HREF][] value.
|
1. Provide the router with an appropriate `APP_BASE_HREF` value.
|
||||||
1. Use root URLs for all web resources: CSS, images, scripts, and template HTML files.
|
1. Use root URLs (URLs with an `authority`) for all web resources: CSS, images, scripts, and template HTML files.
|
||||||
|
|
||||||
|
* The `<base href>` `path` should end with a "/", as browsers ignore characters in the `path` that follow the right-most "/".
|
||||||
|
* If the `<base href>` includes a `query` part, the `query` is only used if the `path` of a link in the page is empty and has no `query`.
|
||||||
|
This means that a `query` in the `<base href>` is only included when using `HashLocationStrategy`.
|
||||||
|
* If a link in the page is a root URL (has an `authority`), the `<base href>` is not used. In this way, an `APP_BASE_HREF` with an authority will cause all links created by Angular to ignore the `<base href>` value.
|
||||||
|
* A fragment in the `<base href>` is _never_ persisted.
|
||||||
|
|
||||||
|
For more complete information on how `<base href>` is used to construct target URIs, see the [RFC](https://tools.ietf.org/html/rfc3986#section-5.2.2) section on transforming references.
|
||||||
|
|
||||||
{@a hashlocationstrategy}
|
{@a hashlocationstrategy}
|
||||||
|
|
||||||
@ -665,7 +682,7 @@ The router resolves that array into a complete URL.
|
|||||||
|
|
||||||
The `RouterLinkActive` directive toggles CSS classes for active `RouterLink` bindings based on the current `RouterState`.
|
The `RouterLinkActive` directive toggles CSS classes for active `RouterLink` bindings based on the current `RouterState`.
|
||||||
|
|
||||||
On each anchor tag, you see a [property binding](guide/template-syntax#property-binding) to the `RouterLinkActive` directive that looks like `routerLinkActive="..."`.
|
On each anchor tag, you see a [property binding](guide/property-binding) to the `RouterLinkActive` directive that looks like `routerLinkActive="..."`.
|
||||||
|
|
||||||
The template expression to the right of the equal sign, `=`, contains a space-delimited string of CSS classes that the Router adds when this link is active (and removes when the link is inactive).
|
The template expression to the right of the equal sign, `=`, contains a space-delimited string of CSS classes that the Router adds when this link is active (and removes when the link is inactive).
|
||||||
You set the `RouterLinkActive` directive to a string of classes such as `[routerLinkActive]="'active fluffy'"` or bind it to a component property that returns such a string.
|
You set the `RouterLinkActive` directive to a string of classes such as `[routerLinkActive]="'active fluffy'"` or bind it to a component property that returns such a string.
|
||||||
|
@ -57,6 +57,20 @@ The task uses the user's preferred package manager to add the library to the pro
|
|||||||
In this example, the function receives the current `Tree` and returns it without any modifications.
|
In this example, the function receives the current `Tree` and returns it without any modifications.
|
||||||
If you need to, you can do additional setup when your package is installed, such as generating files, updating configuration, or any other initial setup your library requires.
|
If you need to, you can do additional setup when your package is installed, such as generating files, updating configuration, or any other initial setup your library requires.
|
||||||
|
|
||||||
|
### Define dependency type
|
||||||
|
|
||||||
|
Use the `save` option of `ng-add` to configure if the library should be added to the `dependencies`, the `devDepedencies`, or not saved at all in the project's `package.json` configuration file.
|
||||||
|
|
||||||
|
<code-example header="projects/my-lib/package.json (ng-add Reference)" path="schematics-for-libraries/projects/my-lib/package.json" region="ng-add">
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
Possible values are:
|
||||||
|
|
||||||
|
* `false` - Don't add the package to package.json
|
||||||
|
* `true` - Add the package to the dependencies
|
||||||
|
* `"dependencies"` - Add the package to the dependencies
|
||||||
|
* `"devDependencies"` - Add the package to the devDependencies
|
||||||
|
|
||||||
## Building your schematics
|
## Building your schematics
|
||||||
|
|
||||||
To bundle your schematics together with your library, you must configure the library to build the schematics separately, then add them to the bundle.
|
To bundle your schematics together with your library, you must configure the library to build the schematics separately, then add them to the bundle.
|
||||||
|
@ -39,14 +39,14 @@ No brackets. No parentheses. Just `*ngIf` set to a string.
|
|||||||
|
|
||||||
You'll learn in this guide that the [asterisk (*) is a convenience notation](guide/structural-directives#asterisk)
|
You'll learn in this guide that the [asterisk (*) is a convenience notation](guide/structural-directives#asterisk)
|
||||||
and the string is a [_microsyntax_](guide/structural-directives#microsyntax) rather than the usual
|
and the string is a [_microsyntax_](guide/structural-directives#microsyntax) rather than the usual
|
||||||
[template expression](guide/template-syntax#template-expressions).
|
[template expression](guide/interpolation#template-expressions).
|
||||||
Angular desugars this notation into a marked-up `<ng-template>` that surrounds the
|
Angular desugars this notation into a marked-up `<ng-template>` that surrounds the
|
||||||
host element and its descendents.
|
host element and its descendants.
|
||||||
Each structural directive does something different with that template.
|
Each structural directive does something different with that template.
|
||||||
|
|
||||||
Three of the common, built-in structural directives—[NgIf](guide/template-syntax#ngIf),
|
Three of the common, built-in structural directives—[NgIf](guide/built-in-directives#ngIf),
|
||||||
[NgFor](guide/template-syntax#ngFor), and [NgSwitch...](guide/template-syntax#ngSwitch)—are
|
[NgFor](guide/built-in-directives#ngFor), and [NgSwitch...](guide/built-in-directives#ngSwitch)—are
|
||||||
described in the [_Template Syntax_](guide/template-syntax) guide and seen in samples throughout the Angular documentation.
|
described in the [Built-in directives](guide/built-in-directives) guide and seen in samples throughout the Angular documentation.
|
||||||
Here's an example of them in a template:
|
Here's an example of them in a template:
|
||||||
|
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ Technically it's a directive with a template.
|
|||||||
|
|
||||||
An [*attribute* directive](guide/attribute-directives) changes the appearance or behavior
|
An [*attribute* directive](guide/attribute-directives) changes the appearance or behavior
|
||||||
of an element, component, or another directive.
|
of an element, component, or another directive.
|
||||||
For example, the built-in [`NgStyle`](guide/template-syntax#ngStyle) directive
|
For example, the built-in [`NgStyle`](guide/built-in-directives#ngStyle) directive
|
||||||
changes several element styles at the same time.
|
changes several element styles at the same time.
|
||||||
|
|
||||||
You can apply many _attribute_ directives to one host element.
|
You can apply many _attribute_ directives to one host element.
|
||||||
@ -440,7 +440,7 @@ There are several such variables in this example: `hero`, `i`, and `odd`.
|
|||||||
All are preceded by the keyword `let`.
|
All are preceded by the keyword `let`.
|
||||||
|
|
||||||
A _template input variable_ is **_not_** the same as a
|
A _template input variable_ is **_not_** the same as a
|
||||||
[template _reference_ variable](guide/template-syntax#ref-vars),
|
[template _reference_ variable](guide/template-reference-variables),
|
||||||
neither _semantically_ nor _syntactically_.
|
neither _semantically_ nor _syntactically_.
|
||||||
|
|
||||||
You declare a template _input_ variable using the `let` keyword (`let hero`).
|
You declare a template _input_ variable using the `let` keyword (`let hero`).
|
||||||
@ -786,7 +786,7 @@ That means the directive needs an `appUnless` property, decorated with `@Input`
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Read about `@Input` in the [_Template Syntax_](guide/template-syntax#inputs-outputs) guide.
|
Read about `@Input` in the [`@Input()` and `@Output()` properties](guide/inputs-outputs) guide.
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -879,12 +879,14 @@ export type LoadingState<T> = Loaded<T> | Loading;
|
|||||||
export class IfLoadedDirective<T> {
|
export class IfLoadedDirective<T> {
|
||||||
@Input('ifLoaded') set state(state: LoadingState<T>) {}
|
@Input('ifLoaded') set state(state: LoadingState<T>) {}
|
||||||
static ngTemplateGuard_state<T>(dir: IfLoadedDirective<T>, expr: LoadingState<T>): expr is Loaded<T> { return true; };
|
static ngTemplateGuard_state<T>(dir: IfLoadedDirective<T>, expr: LoadingState<T>): expr is Loaded<T> { return true; };
|
||||||
|
}
|
||||||
|
|
||||||
export interface Person {
|
export interface Person {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `<div *ifLoaded="state">{{ state.data }}</div>`,
|
template: `<div *ifLoaded="state">{{ state.data }}</div>`,
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
state: LoadingState<Person>;
|
state: LoadingState<Person>;
|
||||||
|
@ -3286,7 +3286,7 @@ helps instantly identify which members of the component serve which purpose.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
**Why?** Angular allows for an [alternative syntax](guide/template-syntax#binding-syntax) `on-*`. If the event itself was prefixed with `on` this would result in an `on-onEvent` binding expression.
|
**Why?** Angular allows for an [alternative syntax](guide/binding-syntax) `on-*`. If the event itself was prefixed with `on` this would result in an `on-onEvent` binding expression.
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
27
aio/content/guide/svg-in-templates.md
Normal file
27
aio/content/guide/svg-in-templates.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# SVG in templates
|
||||||
|
|
||||||
|
It is possible to use SVG as valid templates in Angular. All of the template syntax below is
|
||||||
|
applicable to both SVG and HTML. Learn more in the SVG [1.1](https://www.w3.org/TR/SVG11/) and
|
||||||
|
[2.0](https://www.w3.org/TR/SVG2/) specifications.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example name="template-syntax"></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Why would you use SVG as template, instead of simply adding it as image to your application?
|
||||||
|
|
||||||
|
When you use an SVG as the template, you are able to use directives and bindings just like with HTML
|
||||||
|
templates. This means that you will be able to dynamically generate interactive graphics.
|
||||||
|
|
||||||
|
Refer to the sample code snippet below for a syntax example:
|
||||||
|
|
||||||
|
<code-example path="template-syntax/src/app/svg.component.ts" header="src/app/svg.component.ts"></code-example>
|
||||||
|
|
||||||
|
Add the following code to your `svg.component.svg` file:
|
||||||
|
|
||||||
|
<code-example path="template-syntax/src/app/svg.component.svg" header="src/app/svg.component.svg"></code-example>
|
||||||
|
|
||||||
|
Here you can see the use of a `click()` event binding and the property binding syntax
|
||||||
|
(`[attr.fill]="fillColor"`).
|
144
aio/content/guide/template-expression-operators.md
Normal file
144
aio/content/guide/template-expression-operators.md
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
<!-- {@a expression-operators} -->
|
||||||
|
|
||||||
|
# Template expression operators
|
||||||
|
|
||||||
|
The Angular template expression language employs a subset of JavaScript syntax supplemented with a few special operators
|
||||||
|
for specific scenarios. The next sections cover three of these operators:
|
||||||
|
|
||||||
|
* [pipe](guide/template-expression-operators#pipe)
|
||||||
|
* [safe navigation operator](guide/template-expression-operators#safe-navigation-operator)
|
||||||
|
* [non-null assertion operator](guide/template-expression-operators#non-null-assertion-operator)
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{@a pipe}
|
||||||
|
|
||||||
|
## The pipe operator (`|`)
|
||||||
|
|
||||||
|
The result of an expression might require some transformation before you're ready to use it in a binding.
|
||||||
|
For example, you might display a number as a currency, change text to uppercase, or filter a list and sort it.
|
||||||
|
|
||||||
|
Pipes are simple functions that accept an input value and return a transformed value.
|
||||||
|
They're easy to apply within template expressions, using the pipe operator (`|`):
|
||||||
|
|
||||||
|
<code-example path="template-expression-operators/src/app/app.component.html" region="uppercase-pipe" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The pipe operator passes the result of an expression on the left to a pipe function on the right.
|
||||||
|
|
||||||
|
You can chain expressions through multiple pipes:
|
||||||
|
|
||||||
|
<code-example path="template-expression-operators/src/app/app.component.html" region="pipe-chain" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
And you can also [apply parameters](guide/pipes#parameterizing-a-pipe) to a pipe:
|
||||||
|
|
||||||
|
<code-example path="template-expression-operators/src/app/app.component.html" region="date-pipe" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The `json` pipe is particularly helpful for debugging bindings:
|
||||||
|
|
||||||
|
<code-example path="template-expression-operators/src/app/app.component.html" region="json-pipe" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The generated output would look something like this:
|
||||||
|
|
||||||
|
<code-example language="json">
|
||||||
|
{ "name": "Telephone",
|
||||||
|
"manufactureDate": "1980-02-25T05:00:00.000Z",
|
||||||
|
"price": 98 }
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
The pipe operator has a higher precedence than the ternary operator (`?:`),
|
||||||
|
which means `a ? b : c | x` is parsed as `a ? b : (c | x)`.
|
||||||
|
Nevertheless, for a number of reasons,
|
||||||
|
the pipe operator cannot be used without parentheses in the first and second operands of `?:`.
|
||||||
|
A good practice is to use parentheses in the third operand too.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a safe-navigation-operator}
|
||||||
|
|
||||||
|
## The safe navigation operator ( `?` ) and null property paths
|
||||||
|
|
||||||
|
The Angular safe navigation operator, `?`, guards against `null` and `undefined`
|
||||||
|
values in property paths. Here, it protects against a view render failure if `item` is `null`.
|
||||||
|
|
||||||
|
<code-example path="template-expression-operators/src/app/app.component.html" region="safe" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
If `item` is `null`, the view still renders but the displayed value is blank; you see only "The item name is:" with nothing after it.
|
||||||
|
|
||||||
|
Consider the next example, with a `nullItem`.
|
||||||
|
|
||||||
|
<code-example language="html">
|
||||||
|
The null item name is {{nullItem.name}}
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
Since there is no safe navigation operator and `nullItem` is `null`, JavaScript and Angular would throw a `null` reference error and break the rendering process of Angular:
|
||||||
|
|
||||||
|
<code-example language="bash">
|
||||||
|
TypeError: Cannot read property 'name' of null.
|
||||||
|
</code-example>
|
||||||
|
|
||||||
|
Sometimes however, `null` values in the property
|
||||||
|
path may be OK under certain circumstances,
|
||||||
|
especially when the value starts out null but the data arrives eventually.
|
||||||
|
|
||||||
|
With the safe navigation operator, `?`, Angular stops evaluating the expression when it hits the first `null` value and renders the view without errors.
|
||||||
|
|
||||||
|
It works perfectly with long property paths such as `a?.b?.c?.d`.
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
{@a non-null-assertion-operator}
|
||||||
|
|
||||||
|
## The non-null assertion operator ( `!` )
|
||||||
|
|
||||||
|
As of Typescript 2.0, you can enforce [strict null checking](http://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html "Strict null checking in TypeScript") with the `--strictNullChecks` flag. TypeScript then ensures that no variable is unintentionally `null` or `undefined`.
|
||||||
|
|
||||||
|
In this mode, typed variables disallow `null` and `undefined` by default. The type checker throws an error if you leave a variable unassigned or try to assign `null` or `undefined` to a variable whose type disallows `null` and `undefined`.
|
||||||
|
|
||||||
|
The type checker also throws an error if it can't determine whether a variable will be `null` or `undefined` at runtime. You tell the type checker not to throw an error by applying the postfix
|
||||||
|
[non-null assertion operator, !](http://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#non-null-assertion-operator "Non-null assertion operator").
|
||||||
|
|
||||||
|
The Angular non-null assertion operator, `!`, serves the same purpose in
|
||||||
|
an Angular template. For example, you can assert that `item` properties are also defined.
|
||||||
|
|
||||||
|
<code-example path="template-expression-operators/src/app/app.component.html" region="non-null" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
When the Angular compiler turns your template into TypeScript code,
|
||||||
|
it prevents TypeScript from reporting that `item.color` might be `null` or `undefined`.
|
||||||
|
|
||||||
|
Unlike the [_safe navigation operator_](guide/template-expression-operators#safe-navigation-operator "Safe navigation operator (?)"),
|
||||||
|
the non-null assertion operator does not guard against `null` or `undefined`.
|
||||||
|
Rather, it tells the TypeScript type checker to suspend strict `null` checks for a specific property expression.
|
||||||
|
|
||||||
|
The non-null assertion operator, `!`, is optional with the exception that you must use it when you turn on strict null checks.
|
||||||
|
|
||||||
|
{@a any-type-cast-function}
|
||||||
|
|
||||||
|
## The `$any()` type cast function
|
||||||
|
|
||||||
|
Sometimes a binding expression triggers a type error during [AOT compilation](guide/aot-compiler) and it is not possible or difficult to fully specify the type.
|
||||||
|
To silence the error, you can use the `$any()` cast function to cast
|
||||||
|
the expression to the [`any` type](http://www.typescriptlang.org/docs/handbook/basic-types.html#any) as in the following example:
|
||||||
|
|
||||||
|
<code-example path="built-in-template-functions/src/app/app.component.html" region="any-type-cast-function-1" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
When the Angular compiler turns this template into TypeScript code,
|
||||||
|
it prevents TypeScript from reporting that `bestByDate` is not a member of the `item`
|
||||||
|
object when it runs type checking on the template.
|
||||||
|
|
||||||
|
The `$any()` cast function also works with `this` to allow access to undeclared members of
|
||||||
|
the component.
|
||||||
|
|
||||||
|
<code-example path="built-in-template-functions/src/app/app.component.html" region="any-type-cast-function-2" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The `$any()` cast function works anywhere in a binding expression where a method call is valid.
|
||||||
|
|
69
aio/content/guide/template-reference-variables.md
Normal file
69
aio/content/guide/template-reference-variables.md
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# Template reference variables (`#var`)
|
||||||
|
|
||||||
|
A **template reference variable** is often a reference to a DOM element within a template.
|
||||||
|
It can also refer to a directive (which contains a component), an element, [TemplateRef](api/core/TemplateRef), or a <a href="https://developer.mozilla.org/en-US/docs/Web/Web_Components" title="MDN: Web Components">web component</a>.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
Use the hash symbol (#) to declare a reference variable.
|
||||||
|
The following reference variable, `#phone`, declares a `phone` variable on an `<input>` element.
|
||||||
|
|
||||||
|
<code-example path="template-reference-variables/src/app/app.component.html" region="ref-var" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
You can refer to a template reference variable anywhere in the component's template.
|
||||||
|
Here, a `<button>` further down the template refers to the `phone` variable.
|
||||||
|
|
||||||
|
<code-example path="template-reference-variables/src/app/app.component.html" region="ref-phone" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Angular assigns each template reference variable a value based on where you declare the variable:
|
||||||
|
|
||||||
|
* If you declare the variable on a component, the variable refers to the component instance.
|
||||||
|
* If you declare the variable on a standard HTML tag, the variable refers to the element.
|
||||||
|
* If you declare the variable on an `<ng-template>` element, the variable refers to a `TemplateRef` instance, which represents the template.
|
||||||
|
* If the variable specifies a name on the right-hand side, such as `#var="ngModel"`, the variable refers to the directive or component on the element with a matching `exportAs` name.
|
||||||
|
|
||||||
|
<h3 class="no-toc">How a reference variable gets its value</h3>
|
||||||
|
|
||||||
|
In most cases, Angular sets the reference variable's value to the element on which it is declared.
|
||||||
|
In the previous example, `phone` refers to the phone number `<input>`.
|
||||||
|
The button's click handler passes the `<input>` value to the component's `callPhone()` method.
|
||||||
|
|
||||||
|
The `NgForm` directive can change that behavior and set the value to something else. In the following example, the template reference variable, `itemForm`, appears three times separated
|
||||||
|
by HTML.
|
||||||
|
|
||||||
|
<code-example path="template-reference-variables/src/app/app.component.html" region="ngForm" header="src/app/hero-form.component.html"></code-example>
|
||||||
|
|
||||||
|
The reference value of itemForm, without the ngForm attribute value, would be
|
||||||
|
the [HTMLFormElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement).
|
||||||
|
There is, however, a difference between a Component and a Directive in that a `Component`
|
||||||
|
will be referenced without specifying the attribute value, and a `Directive` will not
|
||||||
|
change the implicit reference (that is, the element).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
However, with `NgForm`, `itemForm` is a reference to the [NgForm](api/forms/NgForm "API: NgForm")
|
||||||
|
directive with the ability to track the value and validity of every control in the form.
|
||||||
|
|
||||||
|
The native `<form>` element doesn't have a `form` property, but the `NgForm` directive does, which allows disabling the submit button
|
||||||
|
if the `itemForm.form.valid` is invalid and passing the entire form control tree
|
||||||
|
to the parent component's `onSubmit()` method.
|
||||||
|
|
||||||
|
<h3 class="no-toc">Template reference variable considerations</h3>
|
||||||
|
|
||||||
|
A template _reference_ variable (`#phone`) is not the same as a template _input_ variable (`let phone`) such as in an [`*ngFor`](guide/built-in-directives#template-input-variable).
|
||||||
|
See [_Structural directives_](guide/structural-directives#template-input-variable) for more information.
|
||||||
|
|
||||||
|
The scope of a reference variable is the entire template. So, don't define the same variable name more than once in the same template as the runtime value will be unpredictable.
|
||||||
|
|
||||||
|
### Alternative syntax
|
||||||
|
|
||||||
|
You can use the `ref-` prefix alternative to `#`.
|
||||||
|
This example declares the `fax` variable as `ref-fax` instead of `#fax`.
|
||||||
|
|
||||||
|
|
||||||
|
<code-example path="template-reference-variables/src/app/app.component.html" region="ref-fax" header="src/app/app.component.html"></code-example>
|
||||||
|
|
65
aio/content/guide/template-statements.md
Normal file
65
aio/content/guide/template-statements.md
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
# Template statements
|
||||||
|
|
||||||
|
A template **statement** responds to an **event** raised by a binding target
|
||||||
|
such as an element, component, or directive.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example name="template-syntax">Template syntax</live-example> for
|
||||||
|
the syntax and code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The following template statement appears in quotes to the right of the `=` symbol as in `(event)="statement"`.
|
||||||
|
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="context-component-statement" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
A template statement *has a side effect*.
|
||||||
|
That's the whole point of an event.
|
||||||
|
It's how you update application state from user action.
|
||||||
|
|
||||||
|
Responding to events is the other side of Angular's "unidirectional data flow".
|
||||||
|
You're free to change anything, anywhere, during this turn of the event loop.
|
||||||
|
|
||||||
|
Like template expressions, template *statements* use a language that looks like JavaScript.
|
||||||
|
The template statement parser differs from the template expression parser and
|
||||||
|
specifically supports both basic assignment (`=`) and chaining expressions with <code>;</code>.
|
||||||
|
|
||||||
|
However, certain JavaScript and template expression syntax is not allowed:
|
||||||
|
|
||||||
|
* <code>new</code>
|
||||||
|
* increment and decrement operators, `++` and `--`
|
||||||
|
* operator assignment, such as `+=` and `-=`
|
||||||
|
* the bitwise operators, such as `|` and `&`
|
||||||
|
* the [pipe operator](guide/template-expression-operators#pipe)
|
||||||
|
|
||||||
|
## Statement context
|
||||||
|
|
||||||
|
As with expressions, statements can refer only to what's in the statement context
|
||||||
|
such as an event handling method of the component instance.
|
||||||
|
|
||||||
|
The *statement context* is typically the component instance.
|
||||||
|
The *deleteHero* in `(click)="deleteHero()"` is a method of the data-bound component.
|
||||||
|
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="context-component-statement" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
The statement context may also refer to properties of the template's own context.
|
||||||
|
In the following examples, the template `$event` object,
|
||||||
|
a [template input variable](guide/built-in-directives#template-input-variable) (`let hero`),
|
||||||
|
and a [template reference variable](guide/template-reference-variables) (`#heroForm`)
|
||||||
|
are passed to an event handling method of the component.
|
||||||
|
|
||||||
|
<code-example path="template-syntax/src/app/app.component.html" region="context-var-statement" header="src/app/app.component.html"></code-example>
|
||||||
|
|
||||||
|
Template context names take precedence over component context names.
|
||||||
|
In `deleteHero(hero)` above, the `hero` is the template input variable,
|
||||||
|
not the component's `hero` property.
|
||||||
|
|
||||||
|
## Statement guidelines
|
||||||
|
|
||||||
|
Template statements cannot refer to anything in the global namespace. They
|
||||||
|
can't refer to `window` or `document`.
|
||||||
|
They can't call `console.log` or `Math.max`.
|
||||||
|
|
||||||
|
As with expressions, avoid writing complex template statements.
|
||||||
|
A method call or simple property assignment should be the norm.
|
File diff suppressed because it is too large
Load Diff
@ -106,8 +106,8 @@ There can also be false positives when the typings of an Angular library are eit
|
|||||||
|
|
||||||
In case of a false positive like these, there are a few options:
|
In case of a false positive like these, there are a few options:
|
||||||
|
|
||||||
* Use the [`$any()` type-cast function](guide/template-syntax#any-type-cast-function) in certain contexts to opt out of type-checking for a part of the expression.
|
* Use the [`$any()` type-cast function](guide/template-expression-operators#any-type-cast-function) in certain contexts to opt out of type-checking for a part of the expression.
|
||||||
* You can disable strict checks entirely by setting `strictTemplates: false` in the application's TypeScript configuration file.
|
* You can disable strict checks entirely by setting `strictTemplates: false` in the application's TypeScript configuration file, `tsconfig.json`.
|
||||||
* You can disable certain type-checking operations individually, while maintaining strictness in other aspects, by setting a _strictness flag_ to `false`.
|
* You can disable certain type-checking operations individually, while maintaining strictness in other aspects, by setting a _strictness flag_ to `false`.
|
||||||
* If you want to use `strictTemplates` and `strictNullChecks` together, you can opt out of strict null type checking specifically for input bindings via `strictNullInputTypes`.
|
* If you want to use `strictTemplates` and `strictNullChecks` together, you can opt out of strict null type checking specifically for input bindings via `strictNullInputTypes`.
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ Care should be taken that if an `ngAcceptInputType_` override is present for a g
|
|||||||
|
|
||||||
## Disabling type checking using `$any()`
|
## Disabling type checking using `$any()`
|
||||||
|
|
||||||
Disable checking of a binding expression by surrounding the expression in a call to the [`$any()` cast pseudo-function](guide/template-syntax).
|
Disable checking of a binding expression by surrounding the expression in a call to the [`$any()` cast pseudo-function](guide/template-expression-operators).
|
||||||
The compiler treats it as a cast to the `any` type just like in TypeScript when a `<any>` or `as any` cast is used.
|
The compiler treats it as a cast to the `any` type just like in TypeScript when a `<any>` or `as any` cast is used.
|
||||||
|
|
||||||
In the following example, casting `person` to the `any` type suppresses the error `Property address does not exist`.
|
In the following example, casting `person` to the `any` type suppresses the error `Property address does not exist`.
|
||||||
|
@ -779,7 +779,7 @@ which reports router activity, is a _hot_ observable.
|
|||||||
|
|
||||||
RxJS marble testing is a rich subject, beyond the scope of this guide.
|
RxJS marble testing is a rich subject, beyond the scope of this guide.
|
||||||
Learn about it on the web, starting with the
|
Learn about it on the web, starting with the
|
||||||
[official documentation](https://github.com/ReactiveX/rxjs/blob/master/doc/writing-marble-tests.md).
|
[official documentation](https://rxjs.dev/guide/testing/marble-testing).
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
76
aio/content/guide/two-way-binding.md
Normal file
76
aio/content/guide/two-way-binding.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# Two-way binding `[(...)]`
|
||||||
|
|
||||||
|
Two-way binding gives your app a way to share data between a component class and
|
||||||
|
its template.
|
||||||
|
|
||||||
|
<div class="alert is-helpful">
|
||||||
|
|
||||||
|
See the <live-example></live-example> for a working example containing the code snippets in this guide.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Basics of two-way binding
|
||||||
|
|
||||||
|
Two-way binding does two things:
|
||||||
|
|
||||||
|
1. Sets a specific element property.
|
||||||
|
1. Listens for an element change event.
|
||||||
|
|
||||||
|
Angular offers a special _two-way data binding_ syntax for this purpose, `[()]`.
|
||||||
|
The `[()]` syntax combines the brackets
|
||||||
|
of property binding, `[]`, with the parentheses of event binding, `()`.
|
||||||
|
|
||||||
|
<div class="callout is-important">
|
||||||
|
|
||||||
|
<header>
|
||||||
|
[( )] = banana in a box
|
||||||
|
</header>
|
||||||
|
|
||||||
|
Visualize a *banana in a box* to remember that the parentheses go _inside_ the brackets.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
The `[()]` syntax is easy to demonstrate when the element has a settable
|
||||||
|
property called `x` and a corresponding event named `xChange`.
|
||||||
|
Here's a `SizerComponent` that fits this pattern.
|
||||||
|
It has a `size` value property and a companion `sizeChange` event:
|
||||||
|
|
||||||
|
<code-example path="two-way-binding/src/app/sizer/sizer.component.ts" header="src/app/sizer.component.ts"></code-example>
|
||||||
|
|
||||||
|
<code-example path="two-way-binding/src/app/sizer/sizer.component.html" header="src/app/sizer.component.html"></code-example>
|
||||||
|
|
||||||
|
The initial `size` is an input value from a property binding.
|
||||||
|
Clicking the buttons increases or decreases the `size`, within
|
||||||
|
min/max value constraints,
|
||||||
|
and then raises, or emits, the `sizeChange` event with the adjusted size.
|
||||||
|
|
||||||
|
Here's an example in which the `AppComponent.fontSizePx` is two-way bound to the `SizerComponent`:
|
||||||
|
|
||||||
|
<code-example path="two-way-binding/src/app/app.component.html" header="src/app/app.component.html (two-way-1)" region="two-way-1"></code-example>
|
||||||
|
|
||||||
|
The `AppComponent.fontSizePx` establishes the initial `SizerComponent.size` value.
|
||||||
|
|
||||||
|
<code-example path="two-way-binding/src/app/app.component.ts" header="src/app/app.component.ts" region="font-size"></code-example>
|
||||||
|
|
||||||
|
Clicking the buttons updates the `AppComponent.fontSizePx` via the two-way binding.
|
||||||
|
The revised `AppComponent.fontSizePx` value flows through to the _style_ binding,
|
||||||
|
making the displayed text bigger or smaller.
|
||||||
|
|
||||||
|
The two-way binding syntax is really just syntactic sugar for a _property_ binding and an _event_ binding.
|
||||||
|
Angular desugars the `SizerComponent` binding into this:
|
||||||
|
|
||||||
|
<code-example path="two-way-binding/src/app/app.component.html" header="src/app/app.component.html (two-way-2)" region="two-way-2"></code-example>
|
||||||
|
|
||||||
|
The `$event` variable contains the payload of the `SizerComponent.sizeChange` event.
|
||||||
|
Angular assigns the `$event` value to the `AppComponent.fontSizePx` when the user clicks the buttons.
|
||||||
|
|
||||||
|
## Two-way binding in forms
|
||||||
|
|
||||||
|
The two-way binding syntax is a great convenience compared to
|
||||||
|
separate property and event bindings. It would be convenient to
|
||||||
|
use two-way binding with HTML form elements like `<input>` and
|
||||||
|
`<select>`. However, no native HTML element follows the `x`
|
||||||
|
value and `xChange` event pattern.
|
||||||
|
|
||||||
|
For more on how to use two-way binding in forms, see
|
||||||
|
Angular [NgModel](guide/built-in-directives#ngModel).
|
@ -227,7 +227,7 @@ as a navigation URL intended for the router.
|
|||||||
|
|
||||||
Fortunately, application routes have something in common: their URLs lack file extensions.
|
Fortunately, application routes have something in common: their URLs lack file extensions.
|
||||||
(Data requests also lack extensions but they're easy to recognize because they always begin with `/api`.)
|
(Data requests also lack extensions but they're easy to recognize because they always begin with `/api`.)
|
||||||
All static asset requests have a file extension (such as `main.js` or `/node_modules/zone.js/bundles/zone.umd.js`).
|
All static asset requests have a file extension (such as `main.js` or `/node_modules/zone.js/dist/zone.js`).
|
||||||
|
|
||||||
Because we use routing, we can easily recognize the three types of requests and handle them differently.
|
Because we use routing, we can easily recognize the three types of requests and handle them differently.
|
||||||
|
|
||||||
|
@ -1567,7 +1567,7 @@ with Angular's two-way `[(ngModel)]` binding syntax:
|
|||||||
<code-example path="upgrade-phonecat-2-hybrid/app/phone-list/phone-list.template.html" region="controls" header="app/phone-list/phone-list.template.html (search controls)"></code-example>
|
<code-example path="upgrade-phonecat-2-hybrid/app/phone-list/phone-list.template.html" region="controls" header="app/phone-list/phone-list.template.html (search controls)"></code-example>
|
||||||
|
|
||||||
Replace the list's `ng-repeat` with an `*ngFor` as
|
Replace the list's `ng-repeat` with an `*ngFor` as
|
||||||
[described in the Template Syntax page](guide/template-syntax#directives).
|
[described in the Template Syntax page](guide/built-in-directives).
|
||||||
Replace the image tag's `ng-src` with a binding to the native `src` property.
|
Replace the image tag's `ng-src` with a binding to the native `src` property.
|
||||||
|
|
||||||
<code-example path="upgrade-phonecat-2-hybrid/app/phone-list/phone-list.template.html" region="list" header="app/phone-list/phone-list.template.html (phones)"></code-example>
|
<code-example path="upgrade-phonecat-2-hybrid/app/phone-list/phone-list.template.html" region="list" header="app/phone-list/phone-list.template.html (phones)"></code-example>
|
||||||
@ -1637,7 +1637,7 @@ There are several notable changes here:
|
|||||||
bindings for the standard `src` property.
|
bindings for the standard `src` property.
|
||||||
|
|
||||||
* You're using the property binding syntax around `ng-class`. Though Angular
|
* You're using the property binding syntax around `ng-class`. Though Angular
|
||||||
does have [a very similar `ngClass`](guide/template-syntax#directives)
|
does have [a very similar `ngClass`](guide/built-in-directives)
|
||||||
as AngularJS does, its value is not magically evaluated as an expression.
|
as AngularJS does, its value is not magically evaluated as an expression.
|
||||||
In Angular, you always specify in the template when an attribute's value is
|
In Angular, you always specify in the template when an attribute's value is
|
||||||
a property expression, as opposed to a literal string.
|
a property expression, as opposed to a literal string.
|
||||||
|
@ -10,13 +10,13 @@ Run the <live-example></live-example>.
|
|||||||
|
|
||||||
## Binding to user input events
|
## Binding to user input events
|
||||||
|
|
||||||
You can use [Angular event bindings](guide/template-syntax#event-binding)
|
You can use [Angular event bindings](guide/event-binding)
|
||||||
to respond to any [DOM event](https://developer.mozilla.org/en-US/docs/Web/Events).
|
to respond to any [DOM event](https://developer.mozilla.org/en-US/docs/Web/Events).
|
||||||
Many DOM events are triggered by user input. Binding to these events provides a way to
|
Many DOM events are triggered by user input. Binding to these events provides a way to
|
||||||
get input from the user.
|
get input from the user.
|
||||||
|
|
||||||
To bind to a DOM event, surround the DOM event name in parentheses and assign a quoted
|
To bind to a DOM event, surround the DOM event name in parentheses and assign a quoted
|
||||||
[template statement](guide/template-syntax#template-statements) to it.
|
[template statement](guide/template-statements) to it.
|
||||||
|
|
||||||
The following example shows an event binding that implements a click handler:
|
The following example shows an event binding that implements a click handler:
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ In this case, `target` refers to the [`<input>` element](https://developer.mozil
|
|||||||
|
|
||||||
After each call, the `onKey()` method appends the contents of the input box value to the list
|
After each call, the `onKey()` method appends the contents of the input box value to the list
|
||||||
in the component's `values` property, followed by a separator character (|).
|
in the component's `values` property, followed by a separator character (|).
|
||||||
The [interpolation](guide/template-syntax#interpolation)
|
The [interpolation](guide/interpolation)
|
||||||
displays the accumulating input box changes from the `values` property.
|
displays the accumulating input box changes from the `values` property.
|
||||||
|
|
||||||
Suppose the user enters the letters "abc", and then backspaces to remove them one by one.
|
Suppose the user enters the letters "abc", and then backspaces to remove them one by one.
|
||||||
@ -139,7 +139,7 @@ The next section shows how to use template reference variables to address this p
|
|||||||
|
|
||||||
## Get user input from a template reference variable
|
## Get user input from a template reference variable
|
||||||
There's another way to get the user data: use Angular
|
There's another way to get the user data: use Angular
|
||||||
[**template reference variables**](guide/template-syntax#ref-vars).
|
[**template reference variables**](guide/template-reference-variables).
|
||||||
These variables provide direct access to an element from within the template.
|
These variables provide direct access to an element from within the template.
|
||||||
To declare a template reference variable, precede an identifier with a hash (or pound) character (#).
|
To declare a template reference variable, precede an identifier with a hash (or pound) character (#).
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ See the [Angular Resources](resources) page for links to the most popular ones.
|
|||||||
Libraries are published as [npm packages](guide/npm-packages), usually together with schematics that integrate them with the Angular CLI.
|
Libraries are published as [npm packages](guide/npm-packages), usually together with schematics that integrate them with the Angular CLI.
|
||||||
To integrate reusable library code into an application, you need to install the package and import the provided functionality where you will use it. For most published Angular libraries, you can use the Angular CLI `ng add <lib_name>` command.
|
To integrate reusable library code into an application, you need to install the package and import the provided functionality where you will use it. For most published Angular libraries, you can use the Angular CLI `ng add <lib_name>` command.
|
||||||
|
|
||||||
The `ng add` command uses the npm package manager or [yarn](https://yarnpkg.com/) to install the library package, and invokes schematics that are included in the package to other scaffolding within the project code, such as adding import statements, fonts, themes, and so on.
|
The `ng add` command uses a package manager such as [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) to install the library package, and invokes schematics that are included in the package to other scaffolding within the project code, such as adding import statements, fonts, themes, and so on.
|
||||||
|
|
||||||
A published library typically provides a README or other documentation on how to add that lib to your app.
|
A published library typically provides a README or other documentation on how to add that lib to your app.
|
||||||
For an example, see [Angular Material](https://material.angular.io/) docs.
|
For an example, see [Angular Material](https://material.angular.io/) docs.
|
||||||
|
BIN
aio/content/images/bios/ajitsinghkaler.jpg
Normal file
BIN
aio/content/images/bios/ajitsinghkaler.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 18 KiB |
BIN
aio/content/images/bios/kevin-kreuzer.jpg
Normal file
BIN
aio/content/images/bios/kevin-kreuzer.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
aio/content/images/bios/twerske.jpg
Normal file
BIN
aio/content/images/bios/twerske.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
@ -576,6 +576,13 @@
|
|||||||
"picture": "cexbrayat.jpg",
|
"picture": "cexbrayat.jpg",
|
||||||
"bio": "Author of `Become a ninja with Angular (2+)` https://books.ninja-squad.com/angular - Angular trainer and @Ninja-Squad co-founder"
|
"bio": "Author of `Become a ninja with Angular (2+)` https://books.ninja-squad.com/angular - Angular trainer and @Ninja-Squad co-founder"
|
||||||
},
|
},
|
||||||
|
"ajitsinghkaler": {
|
||||||
|
"name": "Ajit Singh",
|
||||||
|
"groups": ["Collaborators"],
|
||||||
|
"picture": "ajitsinghkaler.jpg",
|
||||||
|
"twitter": "ajitsinghkaler",
|
||||||
|
"bio": "Software Engineer in Bangalore, India who loves to learn something new and is interested in front end technologies"
|
||||||
|
},
|
||||||
"CaerusKaru": {
|
"CaerusKaru": {
|
||||||
"name": "Adam Plumer",
|
"name": "Adam Plumer",
|
||||||
"groups": ["Collaborators"],
|
"groups": ["Collaborators"],
|
||||||
@ -824,5 +831,22 @@
|
|||||||
"twitter": "ahasall",
|
"twitter": "ahasall",
|
||||||
"website": "https://www.amadousall.com",
|
"website": "https://www.amadousall.com",
|
||||||
"bio": "Amadou is a Frontend Software Engineer from Senegal based in France. He currently works at Air France where he helps developers build better Angular applications. Passionate about web technologies, Amadou is an international speaker, a technical writer, and a Google Developer Expert in Angular."
|
"bio": "Amadou is a Frontend Software Engineer from Senegal based in France. He currently works at Air France where he helps developers build better Angular applications. Passionate about web technologies, Amadou is an international speaker, a technical writer, and a Google Developer Expert in Angular."
|
||||||
|
},
|
||||||
|
"twerske": {
|
||||||
|
"name": "Emma Twersky",
|
||||||
|
"picture": "twerske.jpg",
|
||||||
|
"twitter": "twerske",
|
||||||
|
"website": "http://twerske.github.io",
|
||||||
|
"bio": "Emma is a Developer Advocate at Google. She is passionate about good user experiences and design.",
|
||||||
|
"groups": ["Angular"],
|
||||||
|
"lead": "mgechev"
|
||||||
|
},
|
||||||
|
"kreuzercode": {
|
||||||
|
"name": "Kevin Kreuzer",
|
||||||
|
"picture": "kevin-kreuzer.jpg",
|
||||||
|
"twitter": "kreuzercode",
|
||||||
|
"website": "kreuzercode.com",
|
||||||
|
"bio": "Kevin is a passionate freelance front-end engineer and Google Developer Expert based in Switzerland. He is a JavaScript enthusiast and fascinated by Angular. Kevin always tries to learn new things, expand his knowledge, and share it with others in the form of blog posts, workshops, podcasts, or presentations. He is a writer for various publications and the most active writer on Angular in-depth in 2019. Contributing to multiple projects and maintaining 7 npm packages, Kevin is also a big believer in open source. Furthermore, Kevin is a big football fan. Since his childhood, he has supported Real Madrid, which you might notice in a lot of his blog posts and tutorials.",
|
||||||
|
"groups": ["GDE"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ Most Angular code can be written with just the latest JavaScript, using [types](
|
|||||||
|
|
||||||
## Feedback
|
## Feedback
|
||||||
|
|
||||||
<h4>You can sit with us!</h4>
|
<h3>You can sit with us!</h3>
|
||||||
|
|
||||||
We want to hear from you. [Report problems or submit suggestions for future docs.](https://github.com/angular/angular/issues/new/choose "Angular GitHub repository new issue form")
|
We want to hear from you. [Report problems or submit suggestions for future docs.](https://github.com/angular/angular/issues/new/choose "Angular GitHub repository new issue form")
|
||||||
|
|
||||||
|
@ -189,9 +189,75 @@
|
|||||||
"tooltip": "Property binding helps show app data in the UI."
|
"tooltip": "Property binding helps show app data in the UI."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "guide/template-syntax",
|
|
||||||
"title": "Template Syntax",
|
"title": "Template Syntax",
|
||||||
"tooltip": "Learn how to write templates that display data and consume user events with the help of data binding."
|
"tooltip": "Syntax to use in templates for binding, expressions, and directives.",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"url": "guide/template-syntax",
|
||||||
|
"title": "Introduction",
|
||||||
|
"tooltip": "Introduction to writing templates that display data and consume user events with the help of data binding."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/interpolation",
|
||||||
|
"title": "Interpolation",
|
||||||
|
"tooltip": "An introduction to interpolation and expressions in HTML."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/template-statements",
|
||||||
|
"title": "Template statements",
|
||||||
|
"tooltip": "Introductory guide to statements in templates that respond to events that components, directives, or elements raise."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/binding-syntax",
|
||||||
|
"title": "Binding syntax",
|
||||||
|
"tooltip": "Introductory guide to coordinating app values."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/property-binding",
|
||||||
|
"title": "Property binding",
|
||||||
|
"tooltip": "Introductory guide to setting element or input properties."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/attribute-binding",
|
||||||
|
"title": "Attribute, class, and style bindings",
|
||||||
|
"tooltip": "Introductory guide to setting the value of HTML attributes."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/event-binding",
|
||||||
|
"title": "Event binding",
|
||||||
|
"tooltip": "Introductory guide to listening for user interaction."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/two-way-binding",
|
||||||
|
"title": "Two-way binding",
|
||||||
|
"tooltip": "Introductory guide to sharing data between a class and a template."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/built-in-directives",
|
||||||
|
"title": "Built-in directives",
|
||||||
|
"tooltip": "Introductory guide to some of the most popular built-in directives."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/template-reference-variables",
|
||||||
|
"title": "Template reference variables",
|
||||||
|
"tooltip": "Introductory guide to referring to DOM elements within a template."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/inputs-outputs",
|
||||||
|
"title": "Inputs and Outputs",
|
||||||
|
"tooltip": "Introductory guide to sharing data between parent and child directives or components."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/template-expression-operators",
|
||||||
|
"title": "Template expression operators",
|
||||||
|
"tooltip": "Introductory guide to transforming data, ensuring safe navigation, and guarding against null variables in templates."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "guide/svg-in-templates",
|
||||||
|
"title": "SVG in templates",
|
||||||
|
"tooltip": "Guide to using SVGs as templates to create interactive graphics."
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"url": "guide/user-input",
|
"url": "guide/user-input",
|
||||||
@ -677,11 +743,6 @@
|
|||||||
"url": "guide/creating-libraries",
|
"url": "guide/creating-libraries",
|
||||||
"title": "Creating Libraries",
|
"title": "Creating Libraries",
|
||||||
"tooltip": "Extend Angular by creating, publishing, and using your own libraries."
|
"tooltip": "Extend Angular by creating, publishing, and using your own libraries."
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "guide/lightweight-injection-tokens",
|
|
||||||
"title": "Lightweight Injection Tokens for Libraries",
|
|
||||||
"tooltip": "Optimize client app size by designing library services with lightweight injection tokens."
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -22,7 +22,7 @@ StackBlitz projects are public by default, allowing you to share your Angular ap
|
|||||||
|
|
||||||
To build your application locally or for production, download the source code from your StackBlitz project by clicking the `Download Project` icon in the left menu across from `Project` to download your files.
|
To build your application locally or for production, download the source code from your StackBlitz project by clicking the `Download Project` icon in the left menu across from `Project` to download your files.
|
||||||
|
|
||||||
Once you have the source code downloaded and unzipped, use the [Angular Console](https://angularconsole.com "Angular Console web site") to serve the application, or install `Node.js` and serve your app with the Angular CLI.
|
Once you have the source code downloaded and unzipped, install `Node.js` and serve your app with the Angular CLI.
|
||||||
|
|
||||||
From the terminal, install the Angular CLI globally with:
|
From the terminal, install the Angular CLI globally with:
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ That shows one hero. To list them all, add an `*ngFor` to the `<li>` to iterate
|
|||||||
<code-example path="toh-pt2/src/app/heroes/heroes.component.1.html" region="li">
|
<code-example path="toh-pt2/src/app/heroes/heroes.component.1.html" region="li">
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
The [`*ngFor`](guide/template-syntax#ngFor) is Angular's _repeater_ directive.
|
The [`*ngFor`](guide/built-in-directives#ngFor) is Angular's _repeater_ directive.
|
||||||
It repeats the host element for each element in a list.
|
It repeats the host element for each element in a list.
|
||||||
|
|
||||||
The syntax in this example is as follows:
|
The syntax in this example is as follows:
|
||||||
@ -122,7 +122,7 @@ Add a click event binding to the `<li>` like this:
|
|||||||
|
|
||||||
<code-example path="toh-pt2/src/app/heroes/heroes.component.1.html" region="selectedHero-click" header="heroes.component.html (template excerpt)"></code-example>
|
<code-example path="toh-pt2/src/app/heroes/heroes.component.1.html" region="selectedHero-click" header="heroes.component.html (template excerpt)"></code-example>
|
||||||
|
|
||||||
This is an example of Angular's [event binding](guide/template-syntax#event-binding) syntax.
|
This is an example of Angular's [event binding](guide/event-binding) syntax.
|
||||||
|
|
||||||
The parentheses around `click` tell Angular to listen for the `<li>` element's `click` event.
|
The parentheses around `click` tell Angular to listen for the `<li>` element's `click` event.
|
||||||
When the user clicks in the `<li>`, Angular executes the `onSelect(hero)` expression.
|
When the user clicks in the `<li>`, Angular executes the `onSelect(hero)` expression.
|
||||||
@ -209,7 +209,7 @@ If the user clicks "Magneta", that hero should render with a distinctive but sub
|
|||||||
That _selected hero_ coloring is the work of the `.selected` CSS class in the [styles you added earlier](#styles).
|
That _selected hero_ coloring is the work of the `.selected` CSS class in the [styles you added earlier](#styles).
|
||||||
You just have to apply the `.selected` class to the `<li>` when the user clicks it.
|
You just have to apply the `.selected` class to the `<li>` when the user clicks it.
|
||||||
|
|
||||||
The Angular [class binding](guide/template-syntax#class-binding) makes it easy to add and remove a CSS class conditionally.
|
The Angular [class binding](guide/attribute-binding#class-binding) makes it easy to add and remove a CSS class conditionally.
|
||||||
Just add `[class.some-css-class]="some-condition"` to the element you want to style.
|
Just add `[class.some-css-class]="some-condition"` to the element you want to style.
|
||||||
|
|
||||||
Add the following `[class.selected]` binding to the `<li>` in the `HeroesComponent` template:
|
Add the following `[class.selected]` binding to the `<li>` in the `HeroesComponent` template:
|
||||||
|
@ -62,7 +62,7 @@ region="import-hero" header="src/app/hero-detail/hero-detail.component.ts (impor
|
|||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
The `hero` property
|
The `hero` property
|
||||||
[must be an _Input_ property](guide/template-syntax#inputs-outputs "Input and Output properties"),
|
[must be an _Input_ property](guide/inputs-outputs "Input and Output properties"),
|
||||||
annotated with the `@Input()` decorator,
|
annotated with the `@Input()` decorator,
|
||||||
because the _external_ `HeroesComponent` [will bind to it](#heroes-component-template) like this.
|
because the _external_ `HeroesComponent` [will bind to it](#heroes-component-template) like this.
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ Bind the `HeroesComponent.selectedHero` to the element's `hero` property like th
|
|||||||
|
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
`[hero]="selectedHero"` is an Angular [property binding](guide/template-syntax#property-binding).
|
`[hero]="selectedHero"` is an Angular [property binding](guide/property-binding).
|
||||||
|
|
||||||
It's a _one way_ data binding from
|
It's a _one way_ data binding from
|
||||||
the `selectedHero` property of the `HeroesComponent` to the `hero` property of the target element, which maps to the `hero` property of the `HeroDetailComponent`.
|
the `selectedHero` property of the `HeroesComponent` to the `hero` property of the target element, which maps to the `hero` property of the `HeroDetailComponent`.
|
||||||
@ -165,9 +165,9 @@ Here are the code files discussed on this page.
|
|||||||
* You created a separate, reusable `HeroDetailComponent`.
|
* You created a separate, reusable `HeroDetailComponent`.
|
||||||
|
|
||||||
|
|
||||||
* You used a [property binding](guide/template-syntax#property-binding) to give the parent `HeroesComponent` control over the child `HeroDetailComponent`.
|
* You used a [property binding](guide/property-binding) to give the parent `HeroesComponent` control over the child `HeroDetailComponent`.
|
||||||
|
|
||||||
|
|
||||||
* You used the [`@Input` decorator](guide/template-syntax#inputs-outputs)
|
* You used the [`@Input` decorator](guide/inputs-outputs)
|
||||||
to make the `hero` property available for binding
|
to make the `hero` property available for binding
|
||||||
by the external `HeroesComponent`.
|
by the external `HeroesComponent`.
|
||||||
|
@ -369,7 +369,7 @@ This template binds directly to the component's `messageService`.
|
|||||||
* An `*ngFor` presents the list of messages in repeated `<div>` elements.
|
* An `*ngFor` presents the list of messages in repeated `<div>` elements.
|
||||||
|
|
||||||
|
|
||||||
* An Angular [event binding](guide/template-syntax#event-binding) binds the button's click event
|
* An Angular [event binding](guide/event-binding) binds the button's click event
|
||||||
to `MessageService.clear()`.
|
to `MessageService.clear()`.
|
||||||
|
|
||||||
The messages will look better when you add the private CSS styles to `messages.component.css`
|
The messages will look better when you add the private CSS styles to `messages.component.css`
|
||||||
|
@ -318,7 +318,7 @@ fix the dashboard hero links to navigate via the _parameterized_ dashboard route
|
|||||||
header="src/app/dashboard/dashboard.component.html (hero links)">
|
header="src/app/dashboard/dashboard.component.html (hero links)">
|
||||||
</code-example>
|
</code-example>
|
||||||
|
|
||||||
You're using Angular [interpolation binding](guide/template-syntax#interpolation) within the `*ngFor` repeater
|
You're using Angular [interpolation binding](guide/interpolation) within the `*ngFor` repeater
|
||||||
to insert the current iteration's `hero.id` into each
|
to insert the current iteration's `hero.id` into each
|
||||||
[`routerLink`](#routerlink).
|
[`routerLink`](#routerlink).
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
"build-local-with-viewengine": "yarn ~~build",
|
"build-local-with-viewengine": "yarn ~~build",
|
||||||
"prebuild-local-with-viewengine-ci": "node scripts/switch-to-viewengine && yarn setup-local-ci",
|
"prebuild-local-with-viewengine-ci": "node scripts/switch-to-viewengine && yarn setup-local-ci",
|
||||||
"build-local-with-viewengine-ci": "yarn ~~build --progress=false",
|
"build-local-with-viewengine-ci": "yarn ~~build --progress=false",
|
||||||
"extract-cli-command-docs": "node tools/transforms/cli-docs-package/extract-cli-commands.js b76099083",
|
"extract-cli-command-docs": "node tools/transforms/cli-docs-package/extract-cli-commands.js a404d2a86",
|
||||||
"lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint && yarn tools-lint",
|
"lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint && yarn tools-lint",
|
||||||
"test": "yarn check-env && ng test",
|
"test": "yarn check-env && ng test",
|
||||||
"pree2e": "yarn check-env && yarn update-webdriver",
|
"pree2e": "yarn check-env && yarn update-webdriver",
|
||||||
@ -148,7 +148,7 @@
|
|||||||
"karma-jasmine": "^3.1.1",
|
"karma-jasmine": "^3.1.1",
|
||||||
"karma-jasmine-html-reporter": "^1.4.2",
|
"karma-jasmine-html-reporter": "^1.4.2",
|
||||||
"light-server": "^2.6.2",
|
"light-server": "^2.6.2",
|
||||||
"lighthouse": "^5.1.0",
|
"lighthouse": "6.1.0",
|
||||||
"lighthouse-logger": "^1.2.0",
|
"lighthouse-logger": "^1.2.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"lunr": "^2.1.0",
|
"lunr": "^2.1.0",
|
||||||
|
@ -22,12 +22,12 @@ sh.set('-e');
|
|||||||
const MIN_SCORES_PER_PAGE = {
|
const MIN_SCORES_PER_PAGE = {
|
||||||
'': 100,
|
'': 100,
|
||||||
'api': 100,
|
'api': 100,
|
||||||
'api/core/Directive': 90,
|
'api/core/Directive': 98,
|
||||||
'cli': 91,
|
'cli': 98,
|
||||||
'cli/add': 91,
|
'cli/add': 98,
|
||||||
'docs': 100,
|
'docs': 100,
|
||||||
'guide/docs-style-guide': 88,
|
'guide/docs-style-guide': 95,
|
||||||
'start': 90,
|
'start': 97,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
|
@ -5,13 +5,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<mat-toolbar color="primary" class="app-toolbar no-print" [class.transitioning]="isTransitioning">
|
<mat-toolbar color="primary" class="app-toolbar no-print" [class.transitioning]="isTransitioning">
|
||||||
<mat-toolbar-row class="notification-container">
|
<mat-toolbar-row class="notification-container blm-message">
|
||||||
<aio-notification notificationId="survey-march-2020" expirationDate="2020-04-15" [dismissOnContentClick]="true" (dismissed)="notificationDismissed()">
|
<aio-notification notificationId="blm-2020" expirationDate="2022-04-15" [dismissOnContentClick]="true" (dismissed)="notificationDismissed()">
|
||||||
<a href="https://goo.gle/angular-survey-2020">
|
#BlackLivesMatter
|
||||||
<mat-icon class="icon" svgIcon="insert_comment" aria-label="Announcement"></mat-icon>
|
|
||||||
<span class="message">Help Angular by taking a <b>1 minute survey</b>!</span>
|
|
||||||
<span class="action-button">Go to survey</span>
|
|
||||||
</a>
|
|
||||||
</aio-notification>
|
</aio-notification>
|
||||||
</mat-toolbar-row>
|
</mat-toolbar-row>
|
||||||
<mat-toolbar-row>
|
<mat-toolbar-row>
|
||||||
|
@ -5,63 +5,95 @@
|
|||||||
* - https://github.com/zenorocha/clipboard.js/
|
* - https://github.com/zenorocha/clipboard.js/
|
||||||
*
|
*
|
||||||
* Both released under MIT license - © Zeno Rocha
|
* Both released under MIT license - © Zeno Rocha
|
||||||
|
*
|
||||||
|
* It is also influenced by the Angular CDK `PendingCopy` class:
|
||||||
|
* https://github.com/angular/components/blob/master/src/cdk/clipboard/pending-copy.ts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
export class CopierService {
|
export class CopierService {
|
||||||
private fakeElem: HTMLTextAreaElement|null;
|
/**
|
||||||
|
* Copy the contents of a `<textarea>` element to the clipboard.
|
||||||
|
*
|
||||||
|
* NOTE: For this method to work, the elements must be already inserted into the DOM.
|
||||||
|
*
|
||||||
|
* @param textArea The area containing the text to be copied to the clipboard.
|
||||||
|
* @return Whether the copy operation was successful.
|
||||||
|
*/
|
||||||
|
private copyTextArea(textArea: HTMLTextAreaElement): boolean {
|
||||||
|
const currentFocus = document.activeElement as HTMLOrSVGElement | null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
textArea.select();
|
||||||
|
textArea.setSelectionRange(0, textArea.value.length);
|
||||||
|
|
||||||
|
return document.execCommand('copy');
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
// Calling `.select()` on the `<textarea>` element may have also focused it.
|
||||||
|
// Change the focus back to the previously focused element.
|
||||||
|
currentFocus?.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a fake textarea element, sets its value from `text` property,
|
* Create a temporary, hidden `<textarea>` element and set its value to the specified text.
|
||||||
* and makes a selection on it.
|
*
|
||||||
|
* @param text The text to be inserted into the textarea.
|
||||||
|
* @return The temporary `<textarea>` element containing the specified text.
|
||||||
*/
|
*/
|
||||||
createFake(text: string) {
|
private createTextArea(text: string): HTMLTextAreaElement {
|
||||||
const docElem = document.documentElement!;
|
const docElem = document.documentElement!;
|
||||||
const isRTL = docElem.getAttribute('dir') === 'rtl';
|
const isRTL = docElem.getAttribute('dir') === 'rtl';
|
||||||
|
|
||||||
// Create a fake element to hold the contents to copy
|
// Create a temporary element to hold the contents to copy.
|
||||||
this.fakeElem = document.createElement('textarea');
|
const textArea = document.createElement('textarea');
|
||||||
|
const style = textArea.style;
|
||||||
|
|
||||||
// Prevent zooming on iOS
|
// Prevent zooming on iOS.
|
||||||
this.fakeElem.style.fontSize = '12pt';
|
style.fontSize = '12pt';
|
||||||
|
|
||||||
// Reset box model
|
// Reset box model.
|
||||||
this.fakeElem.style.border = '0';
|
style.border = '0';
|
||||||
this.fakeElem.style.padding = '0';
|
style.padding = '0';
|
||||||
this.fakeElem.style.margin = '0';
|
style.margin = '0';
|
||||||
|
|
||||||
// Move element out of screen horizontally
|
// Make the element invisible and move it out of screen horizontally.
|
||||||
this.fakeElem.style.position = 'absolute';
|
style.opacity = '0';
|
||||||
this.fakeElem.style[ isRTL ? 'right' : 'left' ] = '-9999px';
|
style.position = 'fixed';
|
||||||
|
style.top = '0';
|
||||||
|
style[isRTL ? 'right' : 'left'] = '-999em';
|
||||||
|
|
||||||
// Move element to the same position vertically
|
textArea.setAttribute('aria-hidden', 'true');
|
||||||
const yPosition = window.pageYOffset || docElem.scrollTop;
|
textArea.setAttribute('readonly', '');
|
||||||
this.fakeElem.style.top = yPosition + 'px';
|
textArea.value = text;
|
||||||
|
|
||||||
this.fakeElem.setAttribute('readonly', '');
|
return textArea;
|
||||||
this.fakeElem.value = text;
|
|
||||||
|
|
||||||
document.body.appendChild(this.fakeElem);
|
|
||||||
|
|
||||||
this.fakeElem.select();
|
|
||||||
this.fakeElem.setSelectionRange(0, this.fakeElem.value.length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFake() {
|
/**
|
||||||
if (this.fakeElem) {
|
* Copy the specified text to the clipboard.
|
||||||
document.body.removeChild(this.fakeElem);
|
*
|
||||||
this.fakeElem = null;
|
* @param text The text to be copied to the clipboard.
|
||||||
}
|
* @return Whether the copy operation was successful.
|
||||||
|
*/
|
||||||
|
copyText(text: string): boolean {
|
||||||
|
// Create a `<textarea>` element with the specified text.
|
||||||
|
const textArea = this.createTextArea(text);
|
||||||
|
|
||||||
|
// Insert it into the DOM.
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
|
||||||
|
// Copy its contents to the clipboard.
|
||||||
|
const success = this.copyTextArea(textArea);
|
||||||
|
|
||||||
|
// Remove it from the DOM, so it can be garbage-collected.
|
||||||
|
if (textArea.parentNode) {
|
||||||
|
// We cannot use ChildNode.remove() because of IE11.
|
||||||
|
textArea.parentNode.removeChild(textArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyText(text: string) {
|
return success;
|
||||||
try {
|
|
||||||
this.createFake(text);
|
|
||||||
return document.execCommand('copy');
|
|
||||||
} catch (err) {
|
|
||||||
return false;
|
|
||||||
} finally {
|
|
||||||
this.removeFake();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,33 +39,48 @@ const DEFAULT_NS = '$$default';
|
|||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CustomIconRegistry extends MatIconRegistry {
|
export class CustomIconRegistry extends MatIconRegistry {
|
||||||
private preloadedSvgElements: SvgIconMap = {[DEFAULT_NS]: {}};
|
private cachedSvgElements: SvgIconMap = {[DEFAULT_NS]: {}};
|
||||||
|
|
||||||
constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document: Document,
|
constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document: Document,
|
||||||
errorHandler: ErrorHandler, @Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) {
|
errorHandler: ErrorHandler, @Inject(SVG_ICONS) private svgIcons: SvgIconInfo[]) {
|
||||||
super(http, sanitizer, document, errorHandler);
|
super(http, sanitizer, document, errorHandler);
|
||||||
this.loadSvgElements(svgIcons);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getNamedSvgIcon(iconName: string, namespace?: string) {
|
getNamedSvgIcon(iconName: string, namespace?: string) {
|
||||||
const nsIconMap = this.preloadedSvgElements[namespace || DEFAULT_NS];
|
const nsIconMap = this.cachedSvgElements[namespace || DEFAULT_NS];
|
||||||
const preloadedElement = nsIconMap && nsIconMap[iconName];
|
let preloadedElement: SVGElement | undefined = nsIconMap && nsIconMap[iconName];
|
||||||
|
if (!preloadedElement) {
|
||||||
|
preloadedElement = this.loadSvgElement(iconName, namespace);
|
||||||
|
}
|
||||||
|
|
||||||
return preloadedElement
|
return preloadedElement
|
||||||
? of(preloadedElement.cloneNode(true) as SVGElement)
|
? of(preloadedElement.cloneNode(true) as SVGElement)
|
||||||
: super.getNamedSvgIcon(iconName, namespace);
|
: super.getNamedSvgIcon(iconName, namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadSvgElements(svgIcons: SvgIconInfo[]) {
|
private loadSvgElement(iconName: string, namespace?: string): SVGElement | undefined {
|
||||||
|
const svgIcon = this.svgIcons.find(icon => {
|
||||||
|
return namespace
|
||||||
|
? icon.name === iconName && icon.namespace === namespace
|
||||||
|
: icon.name === iconName;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!svgIcon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ns = svgIcon.namespace || DEFAULT_NS;
|
||||||
|
const nsIconMap = this.cachedSvgElements[ns] || (this.cachedSvgElements[ns] = {});
|
||||||
|
|
||||||
|
// Creating a new `<div>` per icon is necessary for the SVGs to work correctly in IE11.
|
||||||
const div = document.createElement('DIV');
|
const div = document.createElement('DIV');
|
||||||
svgIcons.forEach(icon => {
|
|
||||||
const ns = icon.namespace || DEFAULT_NS;
|
|
||||||
const nsIconMap = this.preloadedSvgElements[ns] || (this.preloadedSvgElements[ns] = {});
|
|
||||||
|
|
||||||
// SECURITY: the source for the SVG icons is provided in code by trusted developers
|
// SECURITY: the source for the SVG icons is provided in code by trusted developers
|
||||||
div.innerHTML = icon.svgSource;
|
div.innerHTML = svgIcon.svgSource;
|
||||||
|
|
||||||
nsIconMap[icon.name] = div.querySelector('svg')!;
|
const svgElement = div.querySelector('svg')!;
|
||||||
});
|
nsIconMap[svgIcon.name] = svgElement;
|
||||||
|
|
||||||
|
return svgElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,6 @@
|
|||||||
Join the community of millions of developers who build compelling user interfaces with Angular.">
|
Join the community of millions of developers who build compelling user interfaces with Angular.">
|
||||||
<base href="/">
|
<base href="/">
|
||||||
|
|
||||||
<link rel="preconnect" href="https://www.google-analytics.com">
|
|
||||||
<link rel="dns-prefetch" href="https://www.google-analytics.com">
|
|
||||||
<link rel="preconnect" href="https://stats.g.doubleclick.net">
|
|
||||||
<link rel="dns-prefetch" href="https://stats.g.doubleclick.net">
|
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<link rel="search" type="application/opensearchdescription+xml" href="assets/opensearch.xml">
|
<link rel="search" type="application/opensearchdescription+xml" href="assets/opensearch.xml">
|
||||||
|
@ -183,8 +183,8 @@ section#intro {
|
|||||||
|
|
||||||
// ANGULAR LINE
|
// ANGULAR LINE
|
||||||
.background-sky {
|
.background-sky {
|
||||||
background-color: $blue;
|
background-color: $black;
|
||||||
background: $bluegradient;
|
background: $black;
|
||||||
color: $white;
|
color: $white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,9 +22,16 @@ mat-toolbar.mat-toolbar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.blm-message {
|
||||||
|
text-align: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: #2d2d2d;
|
||||||
|
font-size: 0.75em;
|
||||||
|
}
|
||||||
|
|
||||||
// HOME PAGE OVERRIDE: TOPNAV TOOLBAR
|
// HOME PAGE OVERRIDE: TOPNAV TOOLBAR
|
||||||
aio-shell.page-home mat-toolbar.mat-toolbar {
|
aio-shell.page-home mat-toolbar.mat-toolbar {
|
||||||
background-color: $blue;
|
background-color: $black;
|
||||||
|
|
||||||
@media (min-width: 481px) {
|
@media (min-width: 481px) {
|
||||||
&:not(.transitioning) {
|
&:not(.transitioning) {
|
||||||
@ -244,6 +251,7 @@ aio-search-box.search-container {
|
|||||||
.toolbar-external-icons-container {
|
.toolbar-external-icons-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
flex-shrink: 0; // This is required for the icons to be displayed correctly in IE11.
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
a {
|
a {
|
||||||
|
@ -103,7 +103,7 @@ aio-api-list {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.material-icons {
|
.material-icons {
|
||||||
color: $blue-grey-100;
|
color: $blue-grey-600;
|
||||||
@include font-size(20);
|
@include font-size(20);
|
||||||
left: 8px;
|
left: 8px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -108,6 +108,7 @@ aio-code pre {
|
|||||||
top: -7px;
|
top: -7px;
|
||||||
right: -19px;
|
right: -19px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
overflow: visible; // This is required for the button to be displayed correctly in IE11.
|
||||||
|
|
||||||
color: $blue-grey-200;
|
color: $blue-grey-200;
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
|
5
aio/src/typings.d.ts
vendored
5
aio/src/typings.d.ts
vendored
@ -1,5 +0,0 @@
|
|||||||
/* SystemJS module definition */
|
|
||||||
declare var module: NodeModule;
|
|
||||||
interface NodeModule {
|
|
||||||
id: string;
|
|
||||||
}
|
|
@ -14,16 +14,3 @@ There, select all the packages that are updated on the new Angular release.
|
|||||||
|
|
||||||
**2)** Changes to the tsconfig.json? There are several files in `/aio/tools/examples/shared/boilerplate/*/tsconfig.json` (based on the example type).
|
**2)** Changes to the tsconfig.json? There are several files in `/aio/tools/examples/shared/boilerplate/*/tsconfig.json` (based on the example type).
|
||||||
|
|
||||||
**3)** The files `/aio/tools/examples/shared/boilerplate/systemjs/src/systemjs.config.web[.build].js` contains the configuration for plunkers. They have some hardcoded versions that could be updated.
|
|
||||||
|
|
||||||
>N.B.: Plunkers have been replaced by Stackblitz and (almost) all examples have be replaced by CLI/WebPack-based examples that do not use SystemJS.
|
|
||||||
The upgrade examples may still rely on SystemJS.
|
|
||||||
|
|
||||||
---
|
|
||||||
> NOTE(gkalpak):
|
|
||||||
> There are some `package.json` files in `/aio/tools/examples/shared/boilerplate/*`.
|
|
||||||
> AFAICT, they are copied over to the examples (based on the example type), but they are neither
|
|
||||||
> used for installing dependencies (which come from `/aio/tools/examples/shared/package.json`) nor
|
|
||||||
> used in zips (since they are overwritten by `/aio/tools/example-zipper/customizer`).
|
|
||||||
> For all stackblitz live-examples, `/aio/tools/examples/shared/boilerplate/cli/package.json` seems
|
|
||||||
> to be used.
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user