Compare commits
339 Commits
2.0.0-alph
...
2.0.0-beta
Author | SHA1 | Date | |
---|---|---|---|
2f5a2ba671 | |||
c45ec6f1be | |||
530470e0ce | |||
ce72ccf9e8 | |||
46d9c87ddc | |||
d736c31fea | |||
a7e9bc97f6 | |||
265703b950 | |||
ae275fa4e4 | |||
3478d5d450 | |||
e72dc16dbe | |||
40a043275d | |||
f161b5cc28 | |||
117d57e121 | |||
3dcce706fd | |||
efb89b83e1 | |||
3d96c2337f | |||
19cfb4eb12 | |||
3d715a2f7b | |||
c7261c295c | |||
1a26f8edd6 | |||
fc887774da | |||
7cbf88a691 | |||
1cb1c139cf | |||
1fd924f7d5 | |||
eb688f2c8e | |||
61cf499b0b | |||
f1f5b45361 | |||
50548fb565 | |||
8f47aa3530 | |||
df7885c9f5 | |||
0f10624b08 | |||
6f1ef33e32 | |||
231773ea76 | |||
e725542703 | |||
2337469753 | |||
55122cd57a | |||
7e0f02f96e | |||
e7ad03cba6 | |||
74be3d3fde | |||
a15ca23469 | |||
de77700da0 | |||
e73fee7156 | |||
72ab35bceb | |||
0f22dce036 | |||
c6036435f0 | |||
d86be245b8 | |||
a26053d3ff | |||
24d5b665e1 | |||
aa98fad338 | |||
9cb6dbbbab | |||
e21718faa9 | |||
b0f7d59e64 | |||
b86829f492 | |||
22929a1671 | |||
86c40f8474 | |||
16b521794c | |||
2a70f4e4c7 | |||
2f31c4c1c5 | |||
1435763383 | |||
05238df89b | |||
772d60d9fe | |||
24086bf0bb | |||
9b0e10e9a7 | |||
995a9e0cf8 | |||
b55f1764b5 | |||
5e9daed2e8 | |||
aa8c5aa2e2 | |||
f2c7946cca | |||
da1fcfd820 | |||
dbeff6f548 | |||
26e60d658a | |||
c2ceb7fba4 | |||
4bfe49cd42 | |||
cee2318110 | |||
cfef76f683 | |||
f56df65d48 | |||
3a40cd79f0 | |||
6acc99729c | |||
99e6500a2d | |||
5c782d6ba8 | |||
4e43d6f769 | |||
3529ee9973 | |||
29aa6a6c1c | |||
7918f3c1fc | |||
2f4e176054 | |||
d4565fdaf3 | |||
2a302aa73a | |||
31b819e9c2 | |||
27daeaff5e | |||
3e9b532409 | |||
c5aa6d17ef | |||
e480b0798e | |||
8a645d5e44 | |||
321193889f | |||
566d3ede04 | |||
8c36aa866a | |||
ed2dbf2db7 | |||
36a0e04604 | |||
8867afdaab | |||
a199772508 | |||
b008f542fa | |||
a78dcfa5f3 | |||
e1bf3d33f8 | |||
ae7d2ab515 | |||
c6adbf602c | |||
1f7a41c963 | |||
f4f614f3a9 | |||
94139c351f | |||
fc5b128b43 | |||
68a799af2e | |||
16d9c60a0e | |||
c0b5e7a672 | |||
6932b29acb | |||
c2a38c05aa | |||
8bea667a0b | |||
800c8f196f | |||
42231f5719 | |||
db87baeb98 | |||
c4c43f5a77 | |||
0ae77753f3 | |||
5f0baaac73 | |||
b5b6ece65a | |||
4282297c24 | |||
9c96b8affc | |||
132829e5e2 | |||
4a414420e9 | |||
fb6335ab60 | |||
89bd008445 | |||
caafb41eb5 | |||
31b81a7439 | |||
f7b1973358 | |||
32f01da49a | |||
59684c97b0 | |||
a32a0a3a97 | |||
96f5b0929d | |||
8e6cf7fca8 | |||
fdbe8741c9 | |||
775fb2c340 | |||
b60f594798 | |||
cc49790bdb | |||
a4bc19c530 | |||
f7985dbdb7 | |||
0bdcb5c1e0 | |||
a0d25db4a5 | |||
625474c4e2 | |||
1cd2a6328a | |||
d6bafe4fe3 | |||
6a2ef15355 | |||
a8ca560503 | |||
ad361808ec | |||
c47639f2b1 | |||
ba90a85f7b | |||
d3b569557f | |||
c9090ffa31 | |||
341bf39d23 | |||
3778ac26aa | |||
6cfc6f5bb2 | |||
47a3b4d56b | |||
c72ed991ad | |||
78bfdf78ea | |||
a24ee6add4 | |||
df3074fdfe | |||
f7424d5aeb | |||
a593ffa6f3 | |||
761c6d0df7 | |||
3e65d1458e | |||
a4b5cb8376 | |||
c785a1e474 | |||
3adc472f06 | |||
e7081b8b7c | |||
9b3a548f6f | |||
90b3502bb8 | |||
e19b31db29 | |||
bd015f14e8 | |||
ca7ba12fc6 | |||
ae05ec69c4 | |||
92dc3b91d8 | |||
8bd697b316 | |||
eda4c3eb4c | |||
4d0c2ed1f6 | |||
eda6a5d52a | |||
c1c54ed0f2 | |||
6b73d09ba1 | |||
ac85cbb28a | |||
b0cebdba6b | |||
933a9112da | |||
8c37b7e8f2 | |||
c8e909f8c9 | |||
69ae3634c7 | |||
95248f46a1 | |||
b3c7df1783 | |||
c56679e8e1 | |||
041c599511 | |||
6343f71be5 | |||
89f32f808f | |||
7ae23adaff | |||
a08f50badd | |||
0b6e75a85e | |||
4291758079 | |||
b44d36cf95 | |||
a038bb9ae3 | |||
9d28147acb | |||
d116861c8e | |||
9a70f1a1d9 | |||
8516473340 | |||
cab69f689f | |||
822e83ebb0 | |||
b2bc50dbd1 | |||
e748adda2e | |||
630d93150a | |||
76f1f9f1e3 | |||
c47d85b038 | |||
197cf09689 | |||
e67ebb7f70 | |||
3524946581 | |||
9276dad42c | |||
2a2f9a9a19 | |||
909e70bd61 | |||
8ac9719832 | |||
3eff7c6f59 | |||
17fbbfba91 | |||
b232dded77 | |||
f50affaf9c | |||
463754bf16 | |||
a45b27e7f9 | |||
af3ea16acb | |||
fc75220d63 | |||
00822c3415 | |||
3dca9d522a | |||
de996ec50b | |||
059e09c3be | |||
d5e4686e7e | |||
d55655f5a3 | |||
61b9468596 | |||
c6f52e3282 | |||
42ccff859c | |||
29600c0c87 | |||
5b63b6764f | |||
2835265916 | |||
e950dd6a2a | |||
321ed7d099 | |||
42b74f524a | |||
77b7caeceb | |||
b803ecf7e7 | |||
d3a79db48d | |||
e891baeea4 | |||
2aaef81b1b | |||
3191fd1440 | |||
80a5e47e61 | |||
5a04ffec3e | |||
1c779d8b9e | |||
a79fe057f9 | |||
b88a6d983f | |||
19396d14cc | |||
2983558e5e | |||
0f8e40bb42 | |||
006a96dd20 | |||
4deaf0bdd3 | |||
9917d7f8af | |||
1607ef8782 | |||
539c5633bf | |||
f83f4ace2d | |||
283962f810 | |||
892f9e19bc | |||
cacfb214b6 | |||
4e5cd1e558 | |||
43f42d9c6e | |||
a885f37dfa | |||
ed2c25eb2f | |||
b1b0593ddf | |||
200dc00dbb | |||
20c6eebb29 | |||
8c69497d8e | |||
44c648fc04 | |||
979162d324 | |||
2934b82113 | |||
92ddc62bed | |||
0cb32c2fef | |||
2ca5e38a78 | |||
b8e69a21a9 | |||
3fd898e91f | |||
a66cc50168 | |||
eb296756fb | |||
f1a9a537cb | |||
080469f8e6 | |||
7c13372721 | |||
778677ba75 | |||
f0d876a873 | |||
e9e2a4152e | |||
398f024b24 | |||
4a17e6906c | |||
8d3e5596dc | |||
df6d2d1e23 | |||
d26c338aa0 | |||
edcb34dc9f | |||
693d9dce5d | |||
194dc7da78 | |||
79399e1c51 | |||
fe1dd77d94 | |||
24dcd267b8 | |||
cf3ce171a5 | |||
06d076a6f2 | |||
3190c5941a | |||
30e25acb9f | |||
4975cb92ae | |||
c8d6ad2718 | |||
cde6726e25 | |||
b3d10af89a | |||
4724cc664e | |||
4e16feaf72 | |||
9e44dd85ad | |||
da9b46a071 | |||
b386d1134a | |||
1e740581ee | |||
f1741b10f2 | |||
7bce1477ef | |||
01ba94ba56 | |||
51cb7586e0 | |||
796eee1e6f | |||
c39828f0f2 | |||
28860d35b2 | |||
5f0ce30ee6 | |||
f4d937ad8d | |||
db096a5e22 | |||
bf484b19b3 | |||
56a254e6a5 | |||
793098bcce | |||
d6d759d722 | |||
61e8b60506 | |||
2f0744b089 | |||
ca73852746 | |||
72444c40a7 | |||
214148d58a | |||
cc8f1f9552 | |||
cbf788869d | |||
c1ae49d91e | |||
4432cf5438 | |||
869a392357 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,6 +22,7 @@ tmp
|
||||
*.js.map
|
||||
|
||||
# Or type definitions we mirror from github
|
||||
# (NB: these lines are removed in publish-build-artifacts.sh)
|
||||
**/typings/**/*.d.ts
|
||||
**/typings/tsd.cached.json
|
||||
|
||||
|
54
.travis.yml
54
.travis.yml
@ -1,17 +1,21 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- '4.2.1'
|
||||
- '5.4.1'
|
||||
|
||||
branches:
|
||||
except:
|
||||
- g3sync
|
||||
- g3_v2_0
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
- $HOME/.pub-cache
|
||||
|
||||
before_cache:
|
||||
# Undo the pollution of the typescript_next build
|
||||
- npm install typescript
|
||||
|
||||
env:
|
||||
global:
|
||||
- KARMA_BROWSERS=DartiumWithWebPlatform
|
||||
@ -36,28 +40,34 @@ env:
|
||||
matrix:
|
||||
# Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete.
|
||||
- MODE=dart DART_CHANNEL=stable DART_VERSION=$DART_STABLE_VERSION
|
||||
- MODE=dart DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=saucelabs DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=browserstack DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=dart_experimental DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
# Disable dart dev build, which is timing out after 2h. #6823
|
||||
# - MODE=dart DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=saucelabs_required DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=browserstack_required DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=saucelabs_optional DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=browserstack_optional DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=dart_ddc DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=js DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=router DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=build_only DART_CHANNEL=stable DART_VERSION=$DART_STABLE_VERSION
|
||||
- MODE=typescript_next DART_CHANNEL=stable DART_VERSION=$DART_STABLE_VERSION
|
||||
- MODE=lint DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION
|
||||
- MODE=payload DART_CHANNEL=stable DART_VERSION=$DART_STABLE_VERSION
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- env: "MODE=saucelabs DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION"
|
||||
- env: "MODE=browserstack DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION"
|
||||
- env: "MODE=dart_experimental DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION"
|
||||
- env: "MODE=saucelabs_optional DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION"
|
||||
- env: "MODE=browserstack_optional DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION"
|
||||
# TODO(alxhub): remove when dartdoc #1039 is in dev channel
|
||||
- env: "MODE=dart DART_CHANNEL=dev DART_VERSION=$DART_DEV_VERSION"
|
||||
# Tracked in https://github.com/angular/angular/issues/7050
|
||||
- env: "MODE=typescript_next DART_CHANNEL=stable DART_VERSION=$DART_STABLE_VERSION"
|
||||
|
||||
addons:
|
||||
firefox: "38.0"
|
||||
|
||||
before_install:
|
||||
- npm install -g npm@3.5.3
|
||||
- node tools/analytics/build-analytics start ci job
|
||||
- node tools/analytics/build-analytics start ci before_install
|
||||
- echo ${TSDRC} > .tsdrc
|
||||
@ -75,7 +85,9 @@ install:
|
||||
# Check the size of caches
|
||||
- du -sh ./node_modules || true
|
||||
# Install npm dependecies
|
||||
- npm install
|
||||
# check-node-modules will exit(1) if we don't need to install
|
||||
# we need to manually kick off the postinstall script if check-node-modules exit(0)s
|
||||
- node tools/npm/check-node-modules --purge && npm install || npm run postinstall
|
||||
- node tools/analytics/build-analytics success ci install
|
||||
|
||||
before_script:
|
||||
@ -103,30 +115,10 @@ notifications:
|
||||
- https://webhooks.gitter.im/e/1ef62e23078036f9cee4
|
||||
# trigger Buildtime Trend Service to parse Travis CI log
|
||||
- https://buildtimetrend.herokuapp.com/travis
|
||||
- http://104.197.9.155:8484/hubot/travis/activity
|
||||
on_success: always # options: [always|never|change] default: always
|
||||
on_failure: always # options: [always|never|change] default: always
|
||||
on_start: false # default: false
|
||||
slack:
|
||||
secure: EP4MzZ8JMyNQJ4S3cd5LEPWSMjC7ZRdzt3veelDiOeorJ6GwZfCDHncR+4BahDzQAuqyE/yNpZqaLbwRWloDi15qIUsm09vgl/1IyNky1Sqc6lEknhzIXpWSalo4/T9ZP8w870EoDvM/UO+LCV99R3wS8Nm9o99eLoWVb2HIUu0=
|
||||
|
||||
deploy:
|
||||
- provider: gcs
|
||||
# This is for project angular-github-babysitter
|
||||
access_key_id: GOOGIOQTDBEOPBUAWFZQ
|
||||
secret_access_key:
|
||||
secure: "MEDggllZ5fw4wI9CEUi8WR6jKsKXqdRF/DLxSNC2JpzM5RlVeBm0uqjntYT1Cf1dASvQ2/+vZCUikL/3A48NcoEYRHXGmxu8D6t/SvleQD8Xv434xFOdsa2QqP/HiCtqCLOI5jJz1JVoB5nNyKKZ33ogTUL1LV1TfcrAioyizW8="
|
||||
# this bucket has a lifecycle to delete after 90 days:
|
||||
# $ echo '{"rule": [{"action": {"type": "Delete"}, "condition": {"age": 90}}]}' > lifecycle.json
|
||||
# $ gsutil lifecycle set lifecycle.json gs://angular2-snapshots
|
||||
bucket: angular2-snapshots
|
||||
# don't delete generated files
|
||||
skip_cleanup: true
|
||||
# serve to public at https://storage.googleapis.com/angular2-snapshots/SHA/dist.tgz
|
||||
acl: public-read
|
||||
# upload the .tgz archive created in scripts/ci/build_and_test.sh
|
||||
local-dir: deploy
|
||||
# create a "subdirectory" for each commit
|
||||
upload-dir: $TRAVIS_COMMIT
|
||||
on:
|
||||
repo: angular/angular
|
||||
condition: "$MODE = build_only"
|
||||
|
488
CHANGELOG.md
488
CHANGELOG.md
@ -1,3 +1,446 @@
|
||||
<a name="2.0.0-beta.7"></a>
|
||||
# 2.0.0-beta.7 (2016-02-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **angular_1_router:** Added DI string tokens ([3478d5d](https://github.com/angular/angular/commit/3478d5d)), closes [#4269](https://github.com/angular/angular/issues/4269) [#7031](https://github.com/angular/angular/issues/7031)
|
||||
* **typing:** Remove re-export of the Promise built-in type. ([265703b](https://github.com/angular/angular/commit/265703b)), closes [#6468](https://github.com/angular/angular/issues/6468)
|
||||
|
||||
<a name="2.0.0-beta.6"></a>
|
||||
# 2.0.0-beta.6 (2016-02-11)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **angular1-router:** add missing wrapper methods ([55122cd](https://github.com/angular/angular/commit/55122cd)), closes [#6763](https://github.com/angular/angular/issues/6763) [#6861](https://github.com/angular/angular/issues/6861) [#6861](https://github.com/angular/angular/issues/6861)
|
||||
* **angular1-router:** add support for using the component helper ([d86be24](https://github.com/angular/angular/commit/d86be24)), closes [angular/angular.js#13860](https://github.com/angular/angular.js/issues/13860) [#6076](https://github.com/angular/angular/issues/6076) [#5278](https://github.com/angular/angular/issues/5278)
|
||||
* **async:** handle synchronous initial value in async pipe ([26e60d6](https://github.com/angular/angular/commit/26e60d6)), closes [#5996](https://github.com/angular/angular/issues/5996)
|
||||
* **build:** don't try to copy .d.ts files into the npm distro ([16b5217](https://github.com/angular/angular/commit/16b5217)), closes [#6921](https://github.com/angular/angular/issues/6921)
|
||||
* **compiler:** fix interpolation regexp ([9b0e10e](https://github.com/angular/angular/commit/9b0e10e)), closes [#6056](https://github.com/angular/angular/issues/6056)
|
||||
* **compiler:** use event names for matching directives ([231773e](https://github.com/angular/angular/commit/231773e)), closes [#6870](https://github.com/angular/angular/issues/6870)
|
||||
* **core:** add detail to dehydrated detector exception ([e7ad03c](https://github.com/angular/angular/commit/e7ad03c)), closes [#6939](https://github.com/angular/angular/issues/6939)
|
||||
* **core:** mute mode printing in console in prod mode ([74be3d3](https://github.com/angular/angular/commit/74be3d3)), closes [#6873](https://github.com/angular/angular/issues/6873)
|
||||
* **di:** throw if a token uses more than 20 dependencies. ([de77700](https://github.com/angular/angular/commit/de77700)), closes [#6690](https://github.com/angular/angular/issues/6690) [#6869](https://github.com/angular/angular/issues/6869)
|
||||
* **forms:** add RadioButtonValueAccessor to the list of default value accessors ([8f47aa3](https://github.com/angular/angular/commit/8f47aa3))
|
||||
* **forms:** add support for radio buttons ([e725542](https://github.com/angular/angular/commit/e725542)), closes [#6877](https://github.com/angular/angular/issues/6877)
|
||||
* **forms:** use strict runtimeType checks instead of instanceof ([50548fb](https://github.com/angular/angular/commit/50548fb)), closes [#6981](https://github.com/angular/angular/issues/6981)
|
||||
* **Headers:** serializable toJSON ([b55f176](https://github.com/angular/angular/commit/b55f176)), closes [#6073](https://github.com/angular/angular/issues/6073) [#6714](https://github.com/angular/angular/issues/6714)
|
||||
* **ngFor:** update view locals if identity changes ([0f10624](https://github.com/angular/angular/commit/0f10624)), closes [#6923](https://github.com/angular/angular/issues/6923)
|
||||
* **router:** Added route data to normalized async route ([df7885c](https://github.com/angular/angular/commit/df7885c)), closes [#6802](https://github.com/angular/angular/issues/6802)
|
||||
* **router:** don't prepend `/` unnecessarily to Location paths ([c603643](https://github.com/angular/angular/commit/c603643)), closes [#6729](https://github.com/angular/angular/issues/6729) [#5502](https://github.com/angular/angular/issues/5502)
|
||||
* **router:** fix incorrect url param value coercion of 1 to true ([995a9e0](https://github.com/angular/angular/commit/995a9e0)), closes [#5346](https://github.com/angular/angular/issues/5346) [#6286](https://github.com/angular/angular/issues/6286)
|
||||
* **router:** fix url path for star segment in path recognizer ([6f1ef33](https://github.com/angular/angular/commit/6f1ef33)), closes [#6976](https://github.com/angular/angular/issues/6976)
|
||||
* **router:** fixed the location wrapper for angular1 ([e73fee7](https://github.com/angular/angular/commit/e73fee7)), closes [#6943](https://github.com/angular/angular/issues/6943)
|
||||
* **typings:** Don't expose typing dependencies to users. ([2a70f4e](https://github.com/angular/angular/commit/2a70f4e)), closes [#5973](https://github.com/angular/angular/issues/5973) [#5807](https://github.com/angular/angular/issues/5807) [#6266](https://github.com/angular/angular/issues/6266) [#5242](https://github.com/angular/angular/issues/5242) [#6817](https://github.com/angular/angular/issues/6817) [#6267](https://github.com/angular/angular/issues/6267)
|
||||
* **upgrade:** fix infinite $rootScope.$digest() ([7e0f02f](https://github.com/angular/angular/commit/7e0f02f)), closes [#6385](https://github.com/angular/angular/issues/6385) [#6386](https://github.com/angular/angular/issues/6386)
|
||||
* **Validators:** fix Validators.required marking number zero as invalid ([c2ceb7f](https://github.com/angular/angular/commit/c2ceb7f)), closes [#6617](https://github.com/angular/angular/issues/6617)
|
||||
* **WebWorkers:** Fix flaky WebWorker test ([da1fcfd](https://github.com/angular/angular/commit/da1fcfd)), closes [#6851](https://github.com/angular/angular/issues/6851)
|
||||
|
||||
### Features
|
||||
|
||||
* **angular1_router:** allow component to bind to router ([0f22dce](https://github.com/angular/angular/commit/0f22dce))
|
||||
* **typings:** install es6-shim typings to a location users can reference. ([f1f5b45](https://github.com/angular/angular/commit/f1f5b45))
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
Transitive typings are no longer included in the distribution.
|
||||
|
||||
If you use `--target=es5`, you will need to add a line somewhere in your
|
||||
application (for example, at the top of the `.ts` file where you call `bootstrap`):
|
||||
```
|
||||
///<reference path="node_modules/angular2/typings/browser.d.ts"/>
|
||||
```
|
||||
(Note that if your file is not in the same directory as `node_modules`, you'll
|
||||
need to add one or more `../` to the start of that path.)
|
||||
|
||||
If you have unit tests, you need to install typings in your project using
|
||||
http://github.com/typings/typings
|
||||
And install typings such as `jasmine`, `angular-protractor`, or `selenium-webdriver`
|
||||
to satisfy the type-checker.
|
||||
|
||||
If you rely on es6 APIs other than Promises and Collections, you will need to
|
||||
install the es6-shim typing instead of using the <reference> tag above.
|
||||
Angular previously exposed typings for the entire ES6 API.
|
||||
|
||||
<a name="2.0.0-beta.5"></a>
|
||||
# 2.0.0-beta.5 (2016-02-10)
|
||||
|
||||
This release was incorrect; replaced with beta.6.
|
||||
|
||||
<a name="2.0.0-beta.4"></a>
|
||||
# 2.0.0-beta.4 (2016-02-10)
|
||||
|
||||
This release was incorrect; replaced with beta.6.
|
||||
|
||||
<a name="2.0.0-beta.3"></a>
|
||||
# 2.0.0-beta.3 (2016-02-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bundle:** add angular2/platform/testing/browser to SystemJS testing bundle ([ae7d2ab](https://github.com/angular/angular/commit/ae7d2ab))
|
||||
* **circle:** pre-dependencies `npm install npm` ([36a0e04](https://github.com/angular/angular/commit/36a0e04)), closes [#6777](https://github.com/angular/angular/issues/6777)
|
||||
* **dart/transform:** Handle edge cases in ReflectionRemover ([3e9b532](https://github.com/angular/angular/commit/3e9b532)), closes [#6749](https://github.com/angular/angular/issues/6749)
|
||||
* **docs:** `rxjs/add/operators/map` -> `rxjs/add/operator/map` (no 's'). ([2a302aa](https://github.com/angular/angular/commit/2a302aa))
|
||||
* **karma:** fix running karma via gulp ([27daeaf](https://github.com/angular/angular/commit/27daeaf))
|
||||
* **query:** don’t cross component boundaries ([c6adbf6](https://github.com/angular/angular/commit/c6adbf6)), closes [#6759](https://github.com/angular/angular/issues/6759)
|
||||
* **query:** update view queries that query directives in embedded views ([1f7a41c](https://github.com/angular/angular/commit/1f7a41c)), closes [#6747](https://github.com/angular/angular/issues/6747)
|
||||
* **WebWorkers:** Add support for transitionend events. ([c2a38c0](https://github.com/angular/angular/commit/c2a38c0)), closes [#6649](https://github.com/angular/angular/issues/6649)
|
||||
* **zone:** correct incorrect calls to zone ([3211938](https://github.com/angular/angular/commit/3211938))
|
||||
|
||||
### Features
|
||||
|
||||
* **change_detection:** allow all legal programs in the dev mode ([42231f5](https://github.com/angular/angular/commit/42231f5))
|
||||
* **dart/transform:** Generate all code into <file>.template.dart ([8c36aa8](https://github.com/angular/angular/commit/8c36aa8))
|
||||
* **debug:** replace DebugElement with new Debug DOM ([e1bf3d3](https://github.com/angular/angular/commit/e1bf3d3))
|
||||
* **ngFor:** add custom trackBy function support ([cee2318](https://github.com/angular/angular/commit/cee2318)), closes [#6779](https://github.com/angular/angular/issues/6779)
|
||||
* **upgrade:** support bindToController with binding definitions ([99e6500](https://github.com/angular/angular/commit/99e6500)), closes [#4784](https://github.com/angular/angular/issues/4784)
|
||||
* **WebWorker:** Add Router Support for WebWorker Apps ([8bea667](https://github.com/angular/angular/commit/8bea667)), closes [#3563](https://github.com/angular/angular/issues/3563)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **dart/transform:** Only process deferred libs when necessary ([f56df65](https://github.com/angular/angular/commit/f56df65)), closes [#6745](https://github.com/angular/angular/issues/6745)
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
This is a breaking change for unit tests. The API for the DebugElement
|
||||
has changed. Now, there is a DebugElement or DebugNode for every node
|
||||
in the DOM, not only nodes with an ElementRef. `componentViewChildren` is
|
||||
removed, and `childNodes` is a list of ElementNodes corresponding to every
|
||||
child in the DOM. `query` no longer takes a scope parameter, since
|
||||
the entire rendered DOM is included in the `childNodes`.
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
componentFixture.debugElement.componentViewChildren[0];
|
||||
```
|
||||
|
||||
After
|
||||
```
|
||||
// Depending on the DOM structure of your component, the
|
||||
// index may have changed or the first component child
|
||||
// may be a sub-child.
|
||||
componentFixture.debugElement.children[0];
|
||||
```
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
debugElement.query(By.css('div'), Scope.all());
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
debugElement.query(By.css('div'));
|
||||
```
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
componentFixture.debugElement.elementRef;
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
componentFixture.elementRef;
|
||||
```
|
||||
|
||||
<a name="2.0.0-beta.2"></a>
|
||||
# 2.0.0-beta.2 (2016-01-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bundles:** testing bundle should include browser platform ([4a41442](https://github.com/angular/angular/commit/4a41442)), closes [#6626](https://github.com/angular/angular/issues/6626)
|
||||
* **ChangeDetection:** chain expressions evaluate to the last expression (codegen) ([933a911](https://github.com/angular/angular/commit/933a911)), closes [#4782](https://github.com/angular/angular/issues/4782) [#5892](https://github.com/angular/angular/issues/5892)
|
||||
* **core:** always remove DOM listeners and stream subscriptions ([0ae7775](https://github.com/angular/angular/commit/0ae7775))
|
||||
* **Dart:** make some playground samples run with Dart Dev Compiler ([3e65d14](https://github.com/angular/angular/commit/3e65d14)), closes [#6441](https://github.com/angular/angular/issues/6441)
|
||||
* **dart/transform:** Ensure template codegen is completed sync ([5f0baaa](https://github.com/angular/angular/commit/5f0baaa)), closes [#6603](https://github.com/angular/angular/issues/6603)
|
||||
* **ddc:** router, compiler, web worker fixes for DDC ([db87bae](https://github.com/angular/angular/commit/db87bae)), closes [#6693](https://github.com/angular/angular/issues/6693)
|
||||
* **ddc:** type fixes necessary to bring DDC severe count to 0 ([4282297](https://github.com/angular/angular/commit/4282297))
|
||||
* **ddc:** use dynamic types in reflection typedefs ([c785a1e](https://github.com/angular/angular/commit/c785a1e)), closes [#6437](https://github.com/angular/angular/issues/6437)
|
||||
* **directive:** throw if output the same event more than once ([8c37b7e](https://github.com/angular/angular/commit/8c37b7e))
|
||||
* **HtmlLexer:** fix for unicode chars ([a24ee6a](https://github.com/angular/angular/commit/a24ee6a)), closes [#6036](https://github.com/angular/angular/issues/6036) [#6061](https://github.com/angular/angular/issues/6061)
|
||||
* **perf:** faster looseIdentical implementation ([761c6d0](https://github.com/angular/angular/commit/761c6d0)), closes [#6364](https://github.com/angular/angular/issues/6364)
|
||||
* **template_compiler:** Fix erroneous cycle detection ([eda4c3e](https://github.com/angular/angular/commit/eda4c3e)), closes [#6404](https://github.com/angular/angular/issues/6404) [#6474](https://github.com/angular/angular/issues/6474)
|
||||
* **testing:** remove test zone for now and rely on returned promises ([c72ed99](https://github.com/angular/angular/commit/c72ed99)), closes [#6359](https://github.com/angular/angular/issues/6359) [#6601](https://github.com/angular/angular/issues/6601)
|
||||
* **transformer:** record HostBinding annotations applied to getters ([a593ffa](https://github.com/angular/angular/commit/a593ffa)), closes [#6283](https://github.com/angular/angular/issues/6283)
|
||||
* **web_workers:** support @AngularEntrypoint in web workers ([ac85cbb](https://github.com/angular/angular/commit/ac85cbb)), closes [#6013](https://github.com/angular/angular/issues/6013)
|
||||
|
||||
### Features
|
||||
|
||||
* **core/application_ref:** Allow asyncronous app initializers. ([df3074f](https://github.com/angular/angular/commit/df3074f)), closes [#5929](https://github.com/angular/angular/issues/5929) [#6063](https://github.com/angular/angular/issues/6063)
|
||||
* **dart/transform:** DirectiveProcessor: do not process generated files ([78bfdf7](https://github.com/angular/angular/commit/78bfdf7)), closes [#6517](https://github.com/angular/angular/issues/6517)
|
||||
* **dart/transform:** Promote missing Directive warning to error ([47a3b4d](https://github.com/angular/angular/commit/47a3b4d)), closes [#6519](https://github.com/angular/angular/issues/6519) [#6568](https://github.com/angular/angular/issues/6568)
|
||||
* **test:** allow tests to specify the platform and application providers used ([b0cebdb](https://github.com/angular/angular/commit/b0cebdb)), closes [#5351](https://github.com/angular/angular/issues/5351) [#5585](https://github.com/angular/angular/issues/5585) [#5975](https://github.com/angular/angular/issues/5975)
|
||||
* **testability:** Expose function frameworkStabilizers ([69ae363](https://github.com/angular/angular/commit/69ae363)), closes [#5485](https://github.com/angular/angular/issues/5485)
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* `Renderer.listen` now has to return a function that
|
||||
removes the event listener.
|
||||
|
||||
* TemplateRef.elementRef is now read-only.
|
||||
|
||||
* Tests are now required to use `setBaseTestProviders`
|
||||
to set up. Assuming your tests are run on a browser, setup would change
|
||||
as follows.
|
||||
Before:
|
||||
```js
|
||||
// Somewhere in test setup
|
||||
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
|
||||
BrowserDomAdapter.makeCurrent
|
||||
```
|
||||
After:
|
||||
```js
|
||||
// Somewhere in the test setup
|
||||
import {setBaseTestProviders} from 'angular2/testing';
|
||||
import {
|
||||
TEST_BROWSER_PLATFORM_PROVIDERS,
|
||||
TEST_BROWSER_APPLICATION_PROVIDERS
|
||||
} from 'angular2/platform/testing/browser';
|
||||
setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS,
|
||||
TEST_BROWSER_APPLICATION_PROVIDERS);
|
||||
```
|
||||
|
||||
|
||||
<a name="2.0.0-beta.1"></a>
|
||||
# 2.0.0-beta.1 catamorphic-involution (2016-01-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **benchpress:** fix flake ([9d28147](https://github.com/angular/angular/commit/9d28147)), closes [#6161](https://github.com/angular/angular/issues/6161)
|
||||
* **CHANGELOG:** typo ([d116861](https://github.com/angular/angular/commit/d116861)), closes [#6075](https://github.com/angular/angular/issues/6075) [#6078](https://github.com/angular/angular/issues/6078)
|
||||
* **code size:** revert previous devMode change to restore size targets ([c47d85b](https://github.com/angular/angular/commit/c47d85b))
|
||||
* **core:** IE only supports parentNode ([630d931](https://github.com/angular/angular/commit/630d931)), closes [#5994](https://github.com/angular/angular/issues/5994)
|
||||
* **docs:** fix an import in TOOLS_DART.md ([3524946](https://github.com/angular/angular/commit/3524946)), closes [#5923](https://github.com/angular/angular/issues/5923)
|
||||
* **forms:** fix SelectControlValueAccessor not to call onChange twice ([b44d36c](https://github.com/angular/angular/commit/b44d36c)), closes [#5969](https://github.com/angular/angular/issues/5969)
|
||||
* **router:** correctly sort route matches with children by specificity ([b2bc50d](https://github.com/angular/angular/commit/b2bc50d)), closes [#5848](https://github.com/angular/angular/issues/5848) [#6011](https://github.com/angular/angular/issues/6011)
|
||||
* **router:** preserve specificity for redirects ([a038bb9](https://github.com/angular/angular/commit/a038bb9)), closes [#5933](https://github.com/angular/angular/issues/5933)
|
||||
* **TemplateParser:** do not match on attrs that are bindings ([9a70f1a](https://github.com/angular/angular/commit/9a70f1a)), closes [#5914](https://github.com/angular/angular/issues/5914)
|
||||
|
||||
### Features
|
||||
|
||||
* **core:** improve NoAnnotationError message ([197cf09](https://github.com/angular/angular/commit/197cf09)), closes [#4866](https://github.com/angular/angular/issues/4866) [#5927](https://github.com/angular/angular/issues/5927)
|
||||
* **core:** improve stringify for dart to handle closures ([e67ebb7](https://github.com/angular/angular/commit/e67ebb7))
|
||||
* **core:** speed up view creation via code gen for view factories. ([7ae23ad](https://github.com/angular/angular/commit/7ae23ad)), closes [#5993](https://github.com/angular/angular/issues/5993)
|
||||
* **router:** support links with just auxiliary routes ([2a2f9a9](https://github.com/angular/angular/commit/2a2f9a9)), closes [#5930](https://github.com/angular/angular/issues/5930)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **dart/transform:** Avoid unnecessary reads for files with no view ([89f32f8](https://github.com/angular/angular/commit/89f32f8)), closes [#6183](https://github.com/angular/angular/issues/6183)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Platform pipes can only contain types and arrays of types,
|
||||
but no bindings any more.
|
||||
* When using transformers, platform pipes need to be specified explicitly
|
||||
in the pubspec.yaml via the new config option
|
||||
`platform_pipes`.
|
||||
* `Compiler.compileInHost` now returns a `HostViewFactoryRef`
|
||||
* Component view is not yet created when component constructor is called.
|
||||
-> use `onInit` lifecycle callback to access the view of a component
|
||||
* `ViewRef#setLocal` has been moved to new type `EmbeddedViewRef`
|
||||
* `internalView` is gone, use `EmbeddedViewRef.rootNodes` to access
|
||||
the root nodes of an embedded view
|
||||
* `renderer.setElementProperty`, `..setElementStyle`, `..setElementAttribute` now
|
||||
take a native element instead of an ElementRef
|
||||
* `Renderer` interface now operates on plain native nodes,
|
||||
instead of `RenderElementRef`s or `RenderViewRef`s
|
||||
|
||||
<a name="2.0.0-beta.0"></a>
|
||||
# 2.0.0-beta.0 somnambulant-inauguration (2015-12-15)
|
||||
|
||||
**Enjoy!**
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.55"></a>
|
||||
# 2.0.0-alpha.55 (2015-12-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **router:** export ROUTER_LINK_DSL_PROVIDER and hide MockPopStateEvent ([fc75220](https://github.com/angular/angular/commit/fc75220))
|
||||
|
||||
### Features
|
||||
|
||||
* **core:** enable dev mode by default ([3dca9d5](https://github.com/angular/angular/commit/3dca9d5))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Previously, Angular would run in dev prod mode by default, and you could enable the dev mode by calling enableDevMode. Now, Angular runs in the dev mode by default, and you can enable the prod mode by calling enableProdMode.
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.54"></a>
|
||||
# 2.0.0-alpha.54 (2015-12-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **bundles:** don't include RxJS in System.register bundles ([77b7cae](https://github.com/angular/angular/commit/77b7cae))
|
||||
* **bundles:** remove ngUpgrade from the angular2.js bundle ([283962f](https://github.com/angular/angular/commit/283962f)), closes [#5739](https://github.com/angular/angular/issues/5739) [#5854](https://github.com/angular/angular/issues/5854)
|
||||
* **bundles:** remove polyfills from angular2.js bundle ([2983558](https://github.com/angular/angular/commit/2983558)), closes [#5881](https://github.com/angular/angular/issues/5881)
|
||||
* **bundles:** rename the testing.js bundle to testing.dev.js ([d55655f](https://github.com/angular/angular/commit/d55655f)), closes [#5899](https://github.com/angular/angular/issues/5899) [#5776](https://github.com/angular/angular/issues/5776)
|
||||
* **bundles:** rename UMD bundles ([61b9468](https://github.com/angular/angular/commit/61b9468)), closes [#5898](https://github.com/angular/angular/issues/5898)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* System.register testing bundle was renamed:
|
||||
`testing.js` -> `testing.dev.js`
|
||||
|
||||
* UMD bundles were renamed:
|
||||
* `angular2.umd.js` -> `angular2-all.umd.js`
|
||||
* `angular2-testing.umd.js` -> `angular2-all-testing.umd.js`
|
||||
|
||||
* RxJS used to be bundled with Angular 2 code and this is not the case
|
||||
any more. RxJS needs to be loaded explicitly.
|
||||
|
||||
* Previously `angular2.js`, `angular2.min.js` and `angular2.dev.js` bundles
|
||||
would have zone.js and reflect-metadata pre-appended. New bundles don't
|
||||
contain zone.js nor reflect-metadata - those external dependencies can
|
||||
be easily loaded into a browser using `angular2-polyfills.js`
|
||||
|
||||
* `ngUpgrade` related symbols are no longer part of the `angular2.js`
|
||||
bundle. `ngUpgrade` has a dedicated `upgrade.js` bundle now.
|
||||
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.53"></a>
|
||||
# 2.0.0-alpha.53 (2015-12-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **angular2:** don't export compiler bits as public API ([20c6eeb](https://github.com/angular/angular/commit/20c6eeb)), closes [#5815](https://github.com/angular/angular/issues/5815) [#5797](https://github.com/angular/angular/issues/5797)
|
||||
* **angular2:** remove `angular2.ts` module ([200dc00](https://github.com/angular/angular/commit/200dc00)), closes [#5815](https://github.com/angular/angular/issues/5815) [#5844](https://github.com/angular/angular/issues/5844)
|
||||
* **animate:** ensure transition properties are removed once the animation is over ([b8e69a2](https://github.com/angular/angular/commit/b8e69a2))
|
||||
* **async:** improve Rx support in ObservableWrapper ([4a17e69](https://github.com/angular/angular/commit/4a17e69))
|
||||
* **async:** support BehaviorSubjects in async pipe ([398f024](https://github.com/angular/angular/commit/398f024))
|
||||
* **bundles:** don't use angular2/angular2 in config of System.register bundles ([8c69497](https://github.com/angular/angular/commit/8c69497))
|
||||
* **changelog:** fix ngFor on template ([3190c59](https://github.com/angular/angular/commit/3190c59)), closes [#5785](https://github.com/angular/angular/issues/5785)
|
||||
* **compiler:** remove AppRootUrl ([ed2c25e](https://github.com/angular/angular/commit/ed2c25e))
|
||||
* **core:** workaround for typescript@1.7.3 breakage #5784 ([30e25ac](https://github.com/angular/angular/commit/30e25ac)), closes [#5784](https://github.com/angular/angular/issues/5784)
|
||||
* **dom_renderer:** moveNodeAfterSiblings should not detach the reference node ([edcb34d](https://github.com/angular/angular/commit/edcb34d)), closes [#5077](https://github.com/angular/angular/issues/5077) [#5759](https://github.com/angular/angular/issues/5759)
|
||||
* **HtmlParser:** allow ng-content elements regardless the namespace ([080469f](https://github.com/angular/angular/commit/080469f)), closes [#5745](https://github.com/angular/angular/issues/5745)
|
||||
* **parse5:** support comment nodes with getText and setText ([693d9dc](https://github.com/angular/angular/commit/693d9dc)), closes [#5805](https://github.com/angular/angular/issues/5805)
|
||||
* **public_spec:** check exports of barrels instead of angular2/angular2 ([979162d](https://github.com/angular/angular/commit/979162d)), closes [#5841](https://github.com/angular/angular/issues/5841)
|
||||
* **styles:** Escape \r characters in compiled text ([92ddc62](https://github.com/angular/angular/commit/92ddc62)), closes [#5772](https://github.com/angular/angular/issues/5772) [#5835](https://github.com/angular/angular/issues/5835)
|
||||
* **TemplateParser:** match element and attributes regardless the namespace ([7c13372](https://github.com/angular/angular/commit/7c13372))
|
||||
* **upgrade:** allow directives with empty template ([2ca5e38](https://github.com/angular/angular/commit/2ca5e38))
|
||||
* **web_workers:** remove unnecessary setup module and AppRootUrl ([a885f37](https://github.com/angular/angular/commit/a885f37)), closes [#5820](https://github.com/angular/angular/issues/5820)
|
||||
|
||||
### Features
|
||||
|
||||
* **benchpress:** add receivedData + requestCount to PerflogMetric ([fe1dd77](https://github.com/angular/angular/commit/fe1dd77)), closes [#5750](https://github.com/angular/angular/issues/5750)
|
||||
* **dom_renderer:** add setBindingDebugInfo method ([79399e1](https://github.com/angular/angular/commit/79399e1)), closes [#5227](https://github.com/angular/angular/issues/5227)
|
||||
* **facade:** do not reexport Observable from angular2/core ([43f42d9](https://github.com/angular/angular/commit/43f42d9))
|
||||
* **Headers:** implement `toJSON` ([0cb32c2](https://github.com/angular/angular/commit/0cb32c2))
|
||||
* **renderer:** use a comment instead of an element when stamping out template>` elements ([194dc7d](https://github.com/angular/angular/commit/194dc7d)), closes [#4805](https://github.com/angular/angular/issues/4805)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* `Observable` are no more re-exported from `angular2/core`
|
||||
|
||||
Before
|
||||
```
|
||||
import {Observable} from 'angular2/core'
|
||||
```
|
||||
After
|
||||
```
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
```
|
||||
|
||||
* The setupWebWorker function exported from
|
||||
angular2/platform/worker_app no longer returns a promise of providers,
|
||||
but instead synchronously returns providers.
|
||||
Related to #5815
|
||||
|
||||
* `angular2/angular2` was removed. Use the correct import from one of the barrels. E.g. `angular2/core`, `angular2/platform/browser`, `angular2/common`, …
|
||||
Note: This only applies to JavaScript, Dart is not changed.
|
||||
|
||||
* The following symbols are not exported from angular2/angular2 any more:
|
||||
`UrlResolver`, `AppRootUrl`, `getUrlScheme`, `DEFAULT_PACKAGE_URL_PROVIDER`.
|
||||
Use imports from `angular2/compiler` instead.
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.52"></a>
|
||||
# 2.0.0-alpha.52 (2015-12-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **core:** case-sensitive camelCase templates (kebab-case removal) ([da9b46a](https://github.com/angular/angular/commit/da9b46a))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Angular templates are now case-sensitive and use camelCase instead of kebab-case (dash-case).
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
<p *ng-if="cond">
|
||||
<my-cmp [my-prop]="exp">
|
||||
<my-cmp (my-event)="action()">
|
||||
<my-cmp [(my-prop)]="prop">
|
||||
<input #my-input>
|
||||
<template ng-for #my-item [ng-for-of]=items #my-index="index">
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
<p *ngIf="cond">
|
||||
<my-cmp [myProp]="exp">
|
||||
<my-cmp (myEvent)="action()">
|
||||
<my-cmp [(myProp)]="prop">
|
||||
<input #myInput>`,
|
||||
<template ngFor "#myItem" [ngForOf]=items #myIndex="index">
|
||||
```
|
||||
|
||||
The full migration instruction can be found at [angular2/docs/migration/kebab-case.md](https://github.com/angular/angular/blob/master/modules/angular2/docs/migration/kebab-case.md).
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.51"></a>
|
||||
# 2.0.0-alpha.51 (2015-12-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **bundles:** add angular2-testing UMD bundle ([d6d759d](https://github.com/angular/angular/commit/d6d759d)), closes [#5581](https://github.com/angular/angular/issues/5581) [#5734](https://github.com/angular/angular/issues/5734)
|
||||
* **core:** provide support for relative assets for components ([28860d3](https://github.com/angular/angular/commit/28860d3)), closes [#5634](https://github.com/angular/angular/issues/5634)
|
||||
* **core:** typescript 1.7.3 compatibility ([#5758](https://github.com/angular/angular/pull/5758))
|
||||
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.50"></a>
|
||||
# 2.0.0-alpha.50 (2015-12-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **http:** fix syntax error in package.json ([869a392](https://github.com/angular/angular/commit/869a3923574de9ed34b953e84e1744cc007ca629)), closes [#5636](https://github.com/angular/angular/issues/5636) [#5726](https://github.com/angular/angular/issues/5726)
|
||||
* **http:** use `any` for res.json() return ([cbf7888](https://github.com/angular/angular/commit/cbf7888)), closes [#5636](https://github.com/angular/angular/issues/5636) [#5646](https://github.com/angular/angular/issues/5646)
|
||||
* **testing:** remove Symbol dummy shim ([c1ae49d](https://github.com/angular/angular/commit/c1ae49d)), closes [#5067](https://github.com/angular/angular/issues/5067) [#5719](https://github.com/angular/angular/issues/5719)
|
||||
* **package:** update RxJS to alpha.14 ([4432cf5](https://github.com/angular/angular/commit/4432cf5438b8c615d297e8965f0ad69f0188169e)), closes [#5722](https://github.com/angular/angular/issues/5722)
|
||||
|
||||
### Features
|
||||
|
||||
* **testing:** package angular2_testing to prepare it for publishing ([cc8f1f9](https://github.com/angular/angular/commit/cc8f1f9)), closes [#5682](https://github.com/angular/angular/issues/5682)
|
||||
|
||||
<a name="2.0.0-alpha.49"></a>
|
||||
# 2.0.0-alpha.49 (2015-12-09)
|
||||
|
||||
@ -50,11 +493,38 @@ Use `angular-polyfills.js` instead.
|
||||
- instrumentation is exported as `ng.instrumentation`
|
||||
- upgrade is exported as `ng.upgrade`
|
||||
|
||||
* Before:
|
||||
<form #f="form">
|
||||
After:
|
||||
<form #f="ngForm">
|
||||
|
||||
* Form directives are exportedAs 'ngForm' (was 'form')
|
||||
|
||||
Before:
|
||||
```html
|
||||
<form #f="form">
|
||||
```
|
||||
|
||||
After:
|
||||
```html
|
||||
<form #f="ngForm">
|
||||
```
|
||||
* rxjs, reflect-metadata, zone.js and es6-shims now must be specified as
|
||||
explicit dependencies of each angular app that uses npm for package management.
|
||||
|
||||
To migrate, please add the following into the "dependencies" section of your package.json:
|
||||
|
||||
```
|
||||
"dependencies": {
|
||||
...
|
||||
|
||||
"es6-promise": "^3.0.2",
|
||||
"es6-shim": "^0.33.3",
|
||||
"reflect-metadata": "0.1.2",
|
||||
"rxjs": "5.0.0-alpha.11",
|
||||
"zone.js": "0.5.8"
|
||||
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
or [check angular2's package.json](https://github.com/angular/angular/blob/master/package.json#L34) for the latest peer dependencies
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.48"></a>
|
||||
# 2.0.0-alpha.48 (2015-12-05)
|
||||
@ -106,15 +576,15 @@ import * as core from 'angular2/core';
|
||||
|
||||
* Operators and Observables from RxJS (e.g. .map(), .toArray(), .toPromise(), etc ) now need to be explicitly imported (once per operator in your app)
|
||||
```
|
||||
import {Observable} from 'angular2/angular2'
|
||||
import 'rxjs/operators/map';
|
||||
import 'rxjs/observable/interval'
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
import 'rxjs/add/observable/interval';
|
||||
|
||||
Observable.interval(1000).subscribe(...);
|
||||
|
||||
http.get('foos.json').map(res => res.json()).subscribe(...);
|
||||
```
|
||||
|
||||
|
||||
<a name="2.0.0-alpha.47"></a>
|
||||
# 2.0.0-alpha.47 (2015-12-01)
|
||||
|
||||
|
@ -11,8 +11,11 @@ Someone with committer access will do the rest.
|
||||
We have automated the process for merging pull requests into master. Our goal is to minimize the disruption for
|
||||
Angular committers and also prevent breakages on master.
|
||||
|
||||
When a PR is ready to merge, a project member in the CoreTeamMember list (see below) can add the special label,
|
||||
`PR: merge`.
|
||||
When a PR has `pr_state: LGTM` and is ready to merge, you should add the `pr_action: merge` label.
|
||||
Currently (late 2015), we need to ensure that each PR will cleanly merge into the Google-internal version control,
|
||||
so the caretaker reviews the changes manually.
|
||||
|
||||
After this review, the caretaker adds `zomg_admin: do_merge` which is restricted to admins only.
|
||||
A robot running as [mary-poppins](https://github.com/mary-poppins)
|
||||
is notified that the label was added by an authorized person,
|
||||
and will create a new branch in the angular project, using the convention `presubmit-{username}-pr-{number}`.
|
||||
@ -26,6 +29,6 @@ Finally, after merge `mary-poppins` removes the presubmit branch.
|
||||
|
||||
## Administration
|
||||
|
||||
The list of users who can trigger a merge by adding the label is stored in our appengine app datastore.
|
||||
The list of users who can trigger a merge by adding the `zomg_admin: do_merge` label is stored in our appengine app datastore.
|
||||
Edit the contents of the [CoreTeamMember Table](
|
||||
https://console.developers.google.com/project/angular2-automation/datastore/query?queryType=KindQuery&namespace=&kind=CoreTeamMember)
|
||||
|
@ -48,14 +48,18 @@ features, by not reporting duplicate issues. Providing the following informatio
|
||||
chances of your issue being dealt with quickly:
|
||||
|
||||
* **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
|
||||
* **Motivation for or Use Case** - explain why this is a bug for you
|
||||
* **Angular Version** - what version of Angular is affected (e.g. 2.0.0-alpha.53)
|
||||
* **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you
|
||||
* **Browsers and Operating System** - is this a problem with all browsers?
|
||||
* **Reproduce the Error** - provide a live example (using [Plunker][plunker],
|
||||
[JSFiddle][jsfiddle] or [Runnable][runnable]) or a unambiguous set of steps.
|
||||
[JSFiddle][jsfiddle] or [Runnable][runnable]) or a unambiguous set of steps
|
||||
* **Related Issues** - has a similar issue been reported before?
|
||||
* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
|
||||
causing the problem (line of code or commit)
|
||||
|
||||
You can file new issues by providing the above information [here](https://github.com/angular/angular/issues/new).
|
||||
|
||||
|
||||
### <a name="submit-pr"></a> Submitting a Pull Request (PR)
|
||||
Before you submit your Pull Request (PR) consider the following guidelines:
|
||||
|
||||
@ -176,7 +180,8 @@ Must be one of the following:
|
||||
* **refactor**: A code change that neither fixes a bug nor adds a feature
|
||||
* **perf**: A code change that improves performance
|
||||
* **test**: Adding missing tests or correcting existing tests
|
||||
* **build** Changes that affect the build system, CI configuration or external dependencies (example scopes: gulp, broccoli, npm)
|
||||
* **build**: Changes that affect the build system, CI configuration or external dependencies (example scopes: gulp, broccoli, npm)
|
||||
* **ci**: Any changes to our CI configuration files and scripts (Travis, Circle CI, BrowserStack, SauceLabs)
|
||||
* **chore**: Other changes that don't modify `src` or `test` files
|
||||
|
||||
### Scope
|
||||
|
44
DEVELOPER.md
44
DEVELOPER.md
@ -9,7 +9,7 @@ JS and Dart versions. It also explains the basic mechanics of using `git`, `node
|
||||
* [Installing NPM Modules and Dart Packages](#installing-npm-modules-and-dart-packages)
|
||||
* [Build commands](#build-commands)
|
||||
* [Running Tests Locally](#running-tests-locally)
|
||||
* [Formatting](#clang-format)
|
||||
* [Code Style](#code-style)
|
||||
* [Project Information](#project-information)
|
||||
* [CI using Travis](#ci-using-travis)
|
||||
* [Transforming Dart code](#transforming-dart-code)
|
||||
@ -23,7 +23,16 @@ if you'd like to contribute to Angular.
|
||||
Before you can build and test Angular, you must install and configure the
|
||||
following products on your development machine:
|
||||
|
||||
* [Dart](https://www.dartlang.org) (version ` >=1.12.0 <2.0.0`), specifically the Dart-SDK and
|
||||
* [Git](http://git-scm.com) and/or the **GitHub app** (for [Mac](http://mac.github.com) or
|
||||
[Windows](http://windows.github.com)); [GitHub's Guide to Installing
|
||||
Git](https://help.github.com/articles/set-up-git) is a good source of information.
|
||||
|
||||
* [Node.js](http://nodejs.org), (version `>=5.4.1 <6`) which is used to run a development web server,
|
||||
run tests, and generate distributable files. We also use Node's Package Manager, `npm`
|
||||
(version `>=3.5.3 <4.0`), which comes with Node. Depending on your system, you can install Node either from
|
||||
source or as a pre-packaged bundle.
|
||||
|
||||
* *Optional*: [Dart](https://www.dartlang.org) (version ` >=1.13.2 <2.0.0`), specifically the Dart-SDK and
|
||||
Dartium (a version of [Chromium](http://www.chromium.org) with native support for Dart through
|
||||
the Dart VM). One of the **simplest** ways to get both is to install the **Dart Editor bundle**,
|
||||
which includes the editor, SDK and Dartium. See the [Dart tools](https://www.dartlang.org/tools)
|
||||
@ -33,19 +42,6 @@ following products on your development machine:
|
||||
to the `Path` (e.g. `path-to-dart-sdk-folder\bin`) and a new `DARTIUM_BIN` environment variable must be
|
||||
created, pointing to the executable (e.g. `path-to-dartium-folder\chrome.exe).`
|
||||
|
||||
* [Git](http://git-scm.com) and/or the **GitHub app** (for [Mac](http://mac.github.com) or
|
||||
[Windows](http://windows.github.com)); [GitHub's Guide to Installing
|
||||
Git](https://help.github.com/articles/set-up-git) is a good source of information.
|
||||
|
||||
* [Node.js](http://nodejs.org), (version `>=4.2.1 <5`) which is used to run a development web server,
|
||||
run tests, and generate distributable files. We also use Node's Package Manager, `npm`
|
||||
(version `>=2.14.7 <3.0`), which comes with Node. Depending on your system, you can install Node either from
|
||||
source or as a pre-packaged bundle.
|
||||
|
||||
* [Chrome Canary](https://www.google.com/chrome/browser/canary.html), a version of Chrome with
|
||||
bleeding edge functionality, built especially for developers (and early adopters).
|
||||
|
||||
* [Bower](http://bower.io/).
|
||||
|
||||
|
||||
## Getting the Sources
|
||||
@ -200,15 +196,15 @@ Then, in another terminal:
|
||||
export SAUCE_USERNAME='my_user'; export SAUCE_ACCESS_KEY='my_key';
|
||||
export BROWSER_STACK_USERNAME='my_user'; export BROWSER_STACK_ACCESS_KEY='my_key';
|
||||
```
|
||||
- Then run `gulp test.unit.js.(saucelabs|browserstack) --browsers=option1,option2,..,optionN`
|
||||
- Then run `gulp test.unit.js.(sauce|browserstack) --browsers=option1,option2,..,optionN`
|
||||
The options are any mix of browsers and aliases which are defined in the [browser-providers.conf.js](https://github.com/angular/angular/blob/master/browser-providers.conf.js) file.
|
||||
They are case insensitive, and the `SL_` or `BS_` prefix must not be added for browsers.
|
||||
|
||||
Some examples of commands:
|
||||
```
|
||||
gulp test.unit.js.saucelabs --browsers=Safari8,ie11 //run in Sauce Labs with Safari 8 and IE11
|
||||
gulp test.unit.js.sauce --browsers=Safari8,ie11 //run in Sauce Labs with Safari 8 and IE11
|
||||
gulp test.unit.js.browserstack --browsers=Safari,IE //run in Browser Stack with Safari 7, Safari 8, Safari 9, IE 9, IE 10 and IE 11
|
||||
gulp test.unit.js.saucelabs --browsers=IOS,safari8,android5.1 //run in Sauce Labs with iOS 7, iOS 8, iOs 9, Safari 8 and Android 5.1
|
||||
gulp test.unit.js.sauce --browsers=IOS,safari8,android5.1 //run in Sauce Labs with iOS 7, iOS 8, iOs 9, Safari 8 and Android 5.1
|
||||
```
|
||||
|
||||
### E2E tests
|
||||
@ -231,7 +227,9 @@ Angular specific command line options when running protractor:
|
||||
Angular specific command line options when running protractor (e.g. force gc, ...):
|
||||
`$(npm bin)/protractor protractor-{js|dart2js}-conf.js --ng-help`
|
||||
|
||||
## Formatting with <a name="clang-format">clang-format</a>
|
||||
## Code Style
|
||||
|
||||
### Formatting with <a name="clang-format">clang-format</a>
|
||||
|
||||
We use [clang-format](http://clang.llvm.org/docs/ClangFormat.html) to automatically enforce code
|
||||
style for our TypeScript code. This allows us to focus our code reviews more on the content, and
|
||||
@ -277,6 +275,14 @@ to some whitespace difference.
|
||||
* `clang-format` integrations are also available for many popular editors (`vim`, `emacs`,
|
||||
`Sublime Text`, etc.).
|
||||
|
||||
### Linting
|
||||
|
||||
We use [tslint](https://github.com/palantir/tslint) for linting. See linting rules in [gulpfile](gulpfile.js). To lint, run
|
||||
|
||||
```shell
|
||||
$ gulp lint
|
||||
```
|
||||
|
||||
## Generating the API documentation
|
||||
|
||||
The following gulp task will generate the API docs in the `dist/angular.io/partials/api/angular2`:
|
||||
|
215
LICENSE
215
LICENSE
@ -1,202 +1,21 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
The MIT License
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
Copyright (c) 2014-2016 Google, Inc. http://angular.io
|
||||
|
||||
1. Definitions.
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
13
README.md
13
README.md
@ -12,20 +12,12 @@ Angular
|
||||
Angular is a development platform for building mobile and desktop web applications. This is the
|
||||
repository for [Angular 2][ng2], both the JavaScript (JS) and [Dart][dart] versions.
|
||||
|
||||
Angular 2 is currently in **Developer Preview**. We recommend using Angular 1.X for production
|
||||
applications:
|
||||
|
||||
* [AngularJS][ngJS]: [angular/angular.js](http://github.com/angular/angular.js).
|
||||
* [AngularDart][ngDart]: [angular/angular.dart](http://github.com/angular/angular.dart).
|
||||
Angular 2 is currently in **Beta**.
|
||||
|
||||
## Quickstart
|
||||
|
||||
[Get started in 5 minutes][quickstart].
|
||||
|
||||
## Setup & Install Angular 2
|
||||
|
||||
Follow the instructions given on the [Angular download page][download].
|
||||
|
||||
|
||||
## Want to help?
|
||||
|
||||
@ -36,8 +28,7 @@ guidelines for [contributing][contributing] and then check out one of our issues
|
||||
[contributing]: http://github.com/angular/angular/blob/master/CONTRIBUTING.md
|
||||
[dart]: http://www.dartlang.org
|
||||
[dartium]: http://www.dartlang.org/tools/dartium
|
||||
[download]: http://angular.io/download/
|
||||
[quickstart]: https://angular.io/docs/js/latest/quickstart.html
|
||||
[quickstart]: https://angular.io/docs/ts/latest/quickstart.html
|
||||
[ng2]: http://angular.io
|
||||
[ngDart]: http://angulardart.org
|
||||
[ngJS]: http://angularjs.org
|
||||
|
@ -21,7 +21,7 @@ By default the debugging tools are disabled.
|
||||
Enable the debugging tools as follows:
|
||||
|
||||
```dart
|
||||
import 'package:angular2/tools.dart';
|
||||
import 'package:angular2/platform/browser.dart';
|
||||
|
||||
main() async {
|
||||
var appRef = await bootstrap(Application);
|
||||
|
@ -1,3 +1,32 @@
|
||||
// Unique place to configure the browsers which are used in the different CI jobs in Sauce Labs (SL) and BrowserStack (BS).
|
||||
// If the target is set to null, then the browser is not run anywhere during CI.
|
||||
// If a category becomes empty (e.g. BS and required), then the corresponding job must be commented out in Travis configuration.
|
||||
var CIconfiguration = {
|
||||
'Chrome': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'Firefox': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'ChromeBeta': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'FirefoxBeta': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'ChromeDev': { unitTest: {target: null, required: true}, e2e: {target: null, required: true}},
|
||||
'FirefoxDev': { unitTest: {target: null, required: true}, e2e: {target: null, required: true}},
|
||||
'IE9': { unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
|
||||
'IE10': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'IE11': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'Edge': { unitTest: {target: 'SL', required: true}, e2e: {target: null, required: true}},
|
||||
'Android4.1': { unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
|
||||
'Android4.2': { unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
|
||||
'Android4.3': { unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
|
||||
'Android4.4': { unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
|
||||
'Android5': { unitTest: {target: 'SL', required: false}, e2e: {target: null, required: true}},
|
||||
'Safari7': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
|
||||
'Safari8': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
|
||||
'Safari9': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
|
||||
'iOS7': { unitTest: {target: 'BS', required: true}, e2e: {target: null, required: true}},
|
||||
'iOS8': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}},
|
||||
// TODO(mlaval): iOS9 deactivated as not reliable, reactivate after https://github.com/angular/angular/issues/5408
|
||||
'iOS9': { unitTest: {target: null, required: false}, e2e: {target: null, required: true}},
|
||||
'WindowsPhone': { unitTest: {target: 'BS', required: false}, e2e: {target: null, required: true}}
|
||||
};
|
||||
|
||||
var customLaunchers = {
|
||||
'DartiumWithWebPlatform': {
|
||||
base: 'Dartium',
|
||||
@ -47,7 +76,7 @@ var customLaunchers = {
|
||||
platform: 'OS X 10.10',
|
||||
version: '8'
|
||||
},
|
||||
'SL_SAFARI9.0': {
|
||||
'SL_SAFARI9': {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'safari',
|
||||
platform: 'OS X 10.11',
|
||||
@ -119,7 +148,7 @@ var customLaunchers = {
|
||||
platform: 'Linux',
|
||||
version: '4.4'
|
||||
},
|
||||
'SL_ANDROID5.1': {
|
||||
'SL_ANDROID5': {
|
||||
base: 'SauceLabs',
|
||||
browserName: 'android',
|
||||
platform: 'Linux',
|
||||
@ -239,21 +268,18 @@ var customLaunchers = {
|
||||
}
|
||||
};
|
||||
|
||||
// iOS9 deactivated as not reliable in both providers
|
||||
// TODO(mlaval): reactivate after https://github.com/angular/angular/issues/5408
|
||||
|
||||
var sauceAliases = {
|
||||
'ALL': Object.keys(customLaunchers).filter(function(item) {return customLaunchers[item].base == 'SauceLabs';}),
|
||||
'DESKTOP': ['SL_CHROME', 'SL_FIREFOX', 'SL_IE9', 'SL_IE10', 'SL_IE11', 'SL_EDGE', 'SL_SAFARI7', 'SL_SAFARI8', 'SL_SAFARI9.0'],
|
||||
'MOBILE': ['SL_ANDROID4.1', 'SL_ANDROID4.2', 'SL_ANDROID4.3', 'SL_ANDROID4.4', 'SL_ANDROID5.1', 'SL_IOS7', 'SL_IOS8', 'SL_IOS9'],
|
||||
'ANDROID': ['SL_ANDROID4.1', 'SL_ANDROID4.2', 'SL_ANDROID4.3', 'SL_ANDROID4.4', 'SL_ANDROID5.1'],
|
||||
'DESKTOP': ['SL_CHROME', 'SL_FIREFOX', 'SL_IE9', 'SL_IE10', 'SL_IE11', 'SL_EDGE', 'SL_SAFARI7', 'SL_SAFARI8', 'SL_SAFARI9'],
|
||||
'MOBILE': ['SL_ANDROID4.1', 'SL_ANDROID4.2', 'SL_ANDROID4.3', 'SL_ANDROID4.4', 'SL_ANDROID5', 'SL_IOS7', 'SL_IOS8', 'SL_IOS9'],
|
||||
'ANDROID': ['SL_ANDROID4.1', 'SL_ANDROID4.2', 'SL_ANDROID4.3', 'SL_ANDROID4.4', 'SL_ANDROID5'],
|
||||
'IE': ['SL_IE9', 'SL_IE10', 'SL_IE11'],
|
||||
'IOS': ['SL_IOS7', 'SL_IOS8', 'SL_IOS9'],
|
||||
'SAFARI': ['SL_SAFARI7', 'SL_SAFARI8', 'SL_SAFARI9.0'],
|
||||
'SAFARI': ['SL_SAFARI7', 'SL_SAFARI8', 'SL_SAFARI9'],
|
||||
'BETA': ['SL_CHROMEBETA', 'SL_FIREFOXBETA'],
|
||||
'DEV': ['SL_CHROMEDEV', 'SL_FIREFOXDEV'],
|
||||
'CI': ['SL_CHROME',' SL_FIREFOX', 'SL_CHROMEDEV', 'SL_FIREFOXBETA', 'SL_IE9', 'SL_IE10', 'SL_IE11', 'SL_EDGE',
|
||||
'SL_ANDROID4.1', 'SL_ANDROID4.2', 'SL_ANDROID4.3', 'SL_ANDROID4.4', 'SL_ANDROID5.1']
|
||||
'CI_REQUIRED': buildConfiguration('unitTest', 'SL', true),
|
||||
'CI_OPTIONAL': buildConfiguration('unitTest', 'SL', false)
|
||||
};
|
||||
|
||||
var browserstackAliases = {
|
||||
@ -264,7 +290,8 @@ var browserstackAliases = {
|
||||
'IE': ['BS_IE9', 'BS_IE10', 'BS_IE11'],
|
||||
'IOS': ['BS_IOS7', 'BS_IOS8', 'BS_IOS9'],
|
||||
'SAFARI': ['BS_SAFARI7', 'BS_SAFARI8', 'BS_SAFARI9'],
|
||||
'CI': ['BS_SAFARI7', 'BS_SAFARI8', 'BS_SAFARI9', 'BS_IOS7', 'BS_IOS8', 'BS_WINDOWSPHONE']
|
||||
'CI_REQUIRED': buildConfiguration('unitTest', 'BS', true),
|
||||
'CI_OPTIONAL': buildConfiguration('unitTest', 'BS', false)
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@ -277,3 +304,14 @@ if (process.env.TRAVIS) {
|
||||
process.env.SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY.split('').reverse().join('');
|
||||
process.env.BROWSER_STACK_ACCESS_KEY = process.env.BROWSER_STACK_ACCESS_KEY.split('').reverse().join('');
|
||||
}
|
||||
|
||||
function buildConfiguration(type, target, required) {
|
||||
return Object.keys(CIconfiguration)
|
||||
.filter((item) => {
|
||||
var conf = CIconfiguration[item][type];
|
||||
return conf.required === required && conf.target === target;
|
||||
})
|
||||
.map((item) => {
|
||||
return target + '_' + item.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
21
circle.yml
Normal file
21
circle.yml
Normal file
@ -0,0 +1,21 @@
|
||||
machine:
|
||||
node:
|
||||
version: 5.4.1
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
- npm install -g npm
|
||||
override:
|
||||
- npm install:
|
||||
environment:
|
||||
# Token for tsd to increase github rate limit
|
||||
# See https://github.com/DefinitelyTyped/tsd#tsdrc
|
||||
# This is not hidden using https://circleci.com/docs/fork-pr-builds#details
|
||||
# because those are not visible for pull requests, and those should also be reliable.
|
||||
# This SSO token belongs to github account angular-github-ratelimit-token which has no access
|
||||
# (password is in Valentine)
|
||||
TSD_GITHUB_TOKEN: ef474500309daea53d5991b3079159a29520a40b
|
||||
|
||||
test:
|
||||
override:
|
||||
- npm run build
|
380
gulpfile.js
380
gulpfile.js
@ -3,10 +3,10 @@
|
||||
// THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
|
||||
// This is to ensure that we catch env issues before we error while requiring other dependencies.
|
||||
require('./tools/check-environment')(
|
||||
{requiredNpmVersion: '>=2.14.7 <3.0.0', requiredNodeVersion: '>=4.2.1 <5.0.0'});
|
||||
{requiredNpmVersion: '>=3.5.3 <4.0.0', requiredNodeVersion: '>=5.4.1 <6.0.0'});
|
||||
|
||||
|
||||
var del = require('del');
|
||||
var fse = require('fs-extra');
|
||||
var gulp = require('gulp');
|
||||
var gulpPlugins = require('gulp-load-plugins')();
|
||||
var merge = require('merge');
|
||||
@ -42,7 +42,7 @@ if (cliArgs.projects) {
|
||||
|
||||
// --projects=angular2,angular2_material => {angular2: true, angular2_material: true}
|
||||
var allProjects =
|
||||
'angular1_router,angular2,angular2_material,benchmarks,benchmarks_external,benchpress,playground,bundle_deps';
|
||||
'angular1_router,angular2,angular2_material,benchmarks,benchmarks_external,benchpress,playground,payload_tests,bundle_deps';
|
||||
var cliArgsProjects = (cliArgs.projects || allProjects)
|
||||
.split(',')
|
||||
.reduce((map, projectName) => {
|
||||
@ -137,35 +137,67 @@ var CONFIG = {
|
||||
dart: 'dist/dart',
|
||||
docs: 'dist/docs',
|
||||
docs_angular_io: 'dist/angular.io',
|
||||
benchpress_bundle: 'dist/build/benchpress_bundle/'
|
||||
bundles: {all: 'dist/build', benchpress: 'dist/build/benchpress_bundle/'}
|
||||
}
|
||||
};
|
||||
|
||||
var ANGULAR2_BUNDLE_CONFIG = [
|
||||
'angular2/common',
|
||||
'angular2/core',
|
||||
'angular2/compiler',
|
||||
'angular2/instrumentation',
|
||||
'angular2/platform/browser',
|
||||
'angular2/platform/common_dom'
|
||||
];
|
||||
|
||||
var NG2_BUNDLE_CONTENT = ANGULAR2_BUNDLE_CONFIG.join(' + ') + ' - rxjs/*';
|
||||
var HTTP_BUNDLE_CONTENT = 'angular2/http - rxjs/* - ' + ANGULAR2_BUNDLE_CONFIG.join(' - ');
|
||||
var ROUTER_BUNDLE_CONTENT = 'angular2/router + angular2/router/router_link_dsl - rxjs/* - ' +
|
||||
ANGULAR2_BUNDLE_CONFIG.join(' - ');
|
||||
var TESTING_BUNDLE_CONTENT =
|
||||
'angular2/testing + angular2/http/testing + angular2/router/testing + angular2/platform/testing/browser - rxjs/* - ' +
|
||||
ANGULAR2_BUNDLE_CONFIG.join(' - ');
|
||||
var UPGRADE_BUNDLE_CONTENT = 'angular2/upgrade - rxjs/* - ' + ANGULAR2_BUNDLE_CONFIG.join(' - ');
|
||||
|
||||
var BENCHPRESS_BUNDLE_CONFIG = {
|
||||
entries: ['./dist/js/cjs/benchpress/index.js'],
|
||||
packageJson: './dist/js/cjs/benchpress/package.json',
|
||||
includes: ['angular2'],
|
||||
excludes: ['reflect-metadata', 'selenium-webdriver', 'zone.js'],
|
||||
ignore: [],
|
||||
dest: CONFIG.dest.benchpress_bundle
|
||||
dest: CONFIG.dest.bundles.benchpress
|
||||
};
|
||||
|
||||
var PAYLOAD_TESTS_CONFIG = {
|
||||
ts: {
|
||||
bundleName: 'app-bundle-deps.min.js',
|
||||
cases: ['hello_world'],
|
||||
dist: function(caseName, packaging) {
|
||||
return path.join(__dirname, CONFIG.dest.js.prod.es5, 'payload_tests', caseName,
|
||||
'ts/' + packaging);
|
||||
},
|
||||
systemjs: {sizeLimits: {'uncompressed': 850 * 1024, 'gzip level=9': 165 * 1024}},
|
||||
webpack: {sizeLimits: {'uncompressed': 550 * 1024, 'gzip level=9': 120 * 1024}}
|
||||
}
|
||||
};
|
||||
|
||||
// ------------
|
||||
// clean
|
||||
|
||||
gulp.task('build/clean.tools', function() { del(path.join('dist', 'tools')); });
|
||||
gulp.task('build/clean.tools', (done) => fse.remove(path.join('dist', 'tools'), done));
|
||||
|
||||
gulp.task('build/clean.js', function(done) { del(CONFIG.dest.js.all, done); });
|
||||
gulp.task('build/clean.js', (done) => fse.remove(CONFIG.dest.js.all, done));
|
||||
|
||||
gulp.task('build/clean.dart', function(done) { del(CONFIG.dest.dart, done); });
|
||||
gulp.task('build/clean.dart', (done) => fse.remove(CONFIG.dest.dart, done));
|
||||
|
||||
gulp.task('build/clean.docs', function(done) { del(CONFIG.dest.docs, done); });
|
||||
gulp.task('build/clean.docs', (done) => fse.remove(CONFIG.dest.docs, done));
|
||||
|
||||
gulp.task('build/clean.docs_angular_io',
|
||||
function(done) { del(CONFIG.dest.docs_angular_io, done); });
|
||||
gulp.task('build/clean.docs_angular_io', (done) => fse.remove(CONFIG.dest.docs_angular_io, done));
|
||||
|
||||
gulp.task('build/clean.benchpress.bundle',
|
||||
function(done) { del(CONFIG.dest.benchpress_bundle, done); });
|
||||
gulp.task('build/clean.bundles', (done) => fse.remove(CONFIG.dest.bundles.all, done));
|
||||
|
||||
gulp.task('build/clean.bundles.benchpress',
|
||||
(done) => fse.remove(CONFIG.dest.bundles.benchpress, done));
|
||||
|
||||
// ------------
|
||||
// transpile
|
||||
@ -293,7 +325,9 @@ gulp.task('lint', ['build.tools'], function() {
|
||||
"requireParameterType": true,
|
||||
"requireReturnType": true,
|
||||
"semicolon": true,
|
||||
"variable-name": [true, "ban-keywords"]
|
||||
|
||||
// TODO: find a way to just screen for reserved names
|
||||
"variable-name": false
|
||||
}
|
||||
};
|
||||
return gulp.src(['modules/angular2/src/**/*.ts', '!modules/angular2/src/testing/**'])
|
||||
@ -349,7 +383,7 @@ function proxyServeDart() {
|
||||
|
||||
// ------------------
|
||||
// web servers
|
||||
gulp.task('serve.js.dev', ['build.js'], function(neverDone) {
|
||||
gulp.task('serve.js.dev', ['build.js.dev'], function(neverDone) {
|
||||
var watch = require('./tools/build/watch');
|
||||
|
||||
watch('modules/**', {ignoreInitial: true}, '!broccoli.js.dev');
|
||||
@ -429,7 +463,7 @@ function runKarma(configFile, done) {
|
||||
|
||||
gulp.task('test.js', function(done) {
|
||||
runSequence('test.unit.tools/ci', 'test.transpiler.unittest', 'test.unit.js/ci',
|
||||
'test.unit.cjs/ci', 'test.typings', sequenceComplete(done));
|
||||
'test.unit.cjs/ci', 'test.typings', 'check-public-api', sequenceComplete(done));
|
||||
});
|
||||
|
||||
gulp.task('test.dart', function(done) {
|
||||
@ -593,7 +627,11 @@ gulp.task('!test.unit.router/karma-run', function(done) {
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('buildRouter.dev', function() { buildRouter(); });
|
||||
gulp.task('buildRouter.dev', function() {
|
||||
var modulesSrcDir = __dirname + '/modules';
|
||||
var distDir = __dirname + '/dist';
|
||||
buildRouter(modulesSrcDir, distDir);
|
||||
});
|
||||
|
||||
gulp.task('test.unit.dart', function(done) {
|
||||
printModulesWarning();
|
||||
@ -618,7 +656,7 @@ gulp.task('test.unit.dart', function(done) {
|
||||
// This test will fail if the size of our hello_world app goes beyond one of
|
||||
// these values when compressed at the specified level.
|
||||
// Measure in bytes.
|
||||
var _DART_PAYLOAD_SIZE_LIMITS = {'uncompressed': 375 * 1024, 'gzip level=6': 105 * 1024};
|
||||
var _DART_PAYLOAD_SIZE_LIMITS = {'uncompressed': 320 * 1024, 'gzip level=9': 90 * 1024};
|
||||
gulp.task('test.payload.dart/ci', function(done) {
|
||||
runSequence('build/packages.dart', '!pubget.payload.dart', '!pubbuild.payload.dart',
|
||||
'!checkAndReport.payload.dart', done);
|
||||
@ -638,6 +676,103 @@ gulp.task('!checkAndReport.payload.dart', function() {
|
||||
{failConditions: _DART_PAYLOAD_SIZE_LIMITS, prefix: 'hello_world'});
|
||||
});
|
||||
|
||||
// JS payload size tracking
|
||||
gulp.task('test.payload.js/ci', function(done) {
|
||||
runSequence('build.payload.js', '!checkAndReport.payload.js', sequenceComplete(done));
|
||||
});
|
||||
|
||||
gulp.task('build.payload.js', ['build.js'], function(done) {
|
||||
runSequence('!build.payload.js.webpack', '!build.payload.js.systemjs', sequenceComplete(done));
|
||||
});
|
||||
|
||||
gulp.task('!build.payload.js.webpack', function() {
|
||||
var q = require('q');
|
||||
var webpack = q.denodeify(require('webpack'));
|
||||
|
||||
var ES5_PROD_ROOT = __dirname + '/' + CONFIG.dest.js.prod.es5;
|
||||
|
||||
return q.all(PAYLOAD_TESTS_CONFIG.ts.cases.map(function(caseName) {
|
||||
var CASE_PATH = PAYLOAD_TESTS_CONFIG.ts.dist(caseName, 'webpack');
|
||||
|
||||
return webpack({
|
||||
// bundle app + framework
|
||||
entry: CASE_PATH + '/index.js',
|
||||
output: {path: CASE_PATH, filename: "app-bundle.js"},
|
||||
resolve: {
|
||||
extensions: ['', '.js'],
|
||||
packageAlias: '', // option added to ignore "broken" package.json in our dist folder
|
||||
root: [ES5_PROD_ROOT]
|
||||
}
|
||||
})
|
||||
.then(function() { // pad bundle with mandatory dependencies
|
||||
return new Promise(function(resolve, reject) {
|
||||
gulp.src([
|
||||
'node_modules/zone.js/dist/zone-microtask.js',
|
||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||
'node_modules/reflect-metadata/Reflect.js',
|
||||
CASE_PATH + '/app-bundle.js'
|
||||
])
|
||||
.pipe(gulpPlugins.concat(PAYLOAD_TESTS_CONFIG.ts.bundleName))
|
||||
.pipe(gulpPlugins.uglify())
|
||||
.pipe(gulp.dest(CASE_PATH))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task('!build.payload.js.systemjs', function() {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
|
||||
return Promise.all(PAYLOAD_TESTS_CONFIG.ts.cases.map(function(caseName) {
|
||||
var CASE_PATH = PAYLOAD_TESTS_CONFIG.ts.dist(caseName, 'systemjs');
|
||||
|
||||
return bundler
|
||||
.bundle(
|
||||
{
|
||||
paths: {'index': CASE_PATH + '/index.js'},
|
||||
meta: {'angular2/core': {build: false}, 'angular2/platform/browser': {build: false}}
|
||||
},
|
||||
'index', CASE_PATH + '/index.register.js', {})
|
||||
.then(function() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
gulp.src([
|
||||
'node_modules/systemjs/dist/system.src.js',
|
||||
'dist/js/prod/es5/bundle/angular2-polyfills.js',
|
||||
'dist/js/prod/es5/bundle/angular2.js',
|
||||
'dist/js/prod/es5//rxjs/bundles/Rx.js',
|
||||
CASE_PATH + '/index.register.js',
|
||||
'tools/build/systemjs/payload_tests_import.js'
|
||||
])
|
||||
.pipe(gulpPlugins.concat(PAYLOAD_TESTS_CONFIG.ts.bundleName))
|
||||
.pipe(gulpPlugins.uglify())
|
||||
.pipe(gulp.dest(CASE_PATH))
|
||||
.on('end', resolve)
|
||||
.on('error', reject);
|
||||
});
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
gulp.task('!checkAndReport.payload.js', function() {
|
||||
var reportSize = require('./tools/analytics/reportsize');
|
||||
|
||||
function caseSizeStream(caseName, packaging) {
|
||||
return reportSize(PAYLOAD_TESTS_CONFIG.ts.dist(caseName, packaging) + '/' +
|
||||
PAYLOAD_TESTS_CONFIG.ts.bundleName,
|
||||
{
|
||||
failConditions: PAYLOAD_TESTS_CONFIG.ts[packaging].sizeLimits,
|
||||
prefix: caseName + '_' + packaging
|
||||
})
|
||||
}
|
||||
|
||||
return PAYLOAD_TESTS_CONFIG.ts.cases.reduce(function(sizeReportingStreams, caseName) {
|
||||
sizeReportingStreams.add(caseSizeStream(caseName, 'systemjs'));
|
||||
sizeReportingStreams.add(caseSizeStream(caseName, 'webpack'));
|
||||
}, merge2());
|
||||
});
|
||||
|
||||
gulp.task('watch.dart.dev', function(done) {
|
||||
runSequence('build/tree.dart', 'build/pure-packages.dart', '!build/pubget.angular2.dart',
|
||||
'!build/change_detect.dart', '!build/remove-pub-symlinks', 'build.dart.material.css',
|
||||
@ -695,17 +830,24 @@ gulp.task('test.unit.js/ci', function(done) {
|
||||
reporters: ['dots'],
|
||||
browsers: browserConf.browsersToRun
|
||||
},
|
||||
done)
|
||||
function(err) { done(); })
|
||||
.start();
|
||||
});
|
||||
|
||||
gulp.task('test.unit.js.sauce/ci', function(done) {
|
||||
launchKarmaWithExternalBrowsers(['dots', 'saucelabs'], browserProvidersConf.sauceAliases.CI,
|
||||
done);
|
||||
var browsers = browserProvidersConf.sauceAliases.CI_REQUIRED;
|
||||
if (cliArgs.mode && cliArgs.mode == 'saucelabs_optional') {
|
||||
browsers = browserProvidersConf.sauceAliases.CI_OPTIONAL;
|
||||
}
|
||||
launchKarmaWithExternalBrowsers(['dots', 'saucelabs'], browsers, done);
|
||||
});
|
||||
|
||||
gulp.task('test.unit.js.browserstack/ci', function(done) {
|
||||
launchKarmaWithExternalBrowsers(['dots'], browserProvidersConf.browserstackAliases.CI, done);
|
||||
var browsers = browserProvidersConf.browserstackAliases.CI_REQUIRED;
|
||||
if (cliArgs.mode && cliArgs.mode == 'browserstack_optional') {
|
||||
browsers = browserProvidersConf.browserstackAliases.CI_OPTIONAL;
|
||||
}
|
||||
launchKarmaWithExternalBrowsers(['dots'], browsers, done);
|
||||
});
|
||||
|
||||
gulp.task('test.unit.dart/ci', function(done) {
|
||||
@ -728,6 +870,8 @@ gulp.task('test.unit.cjs/ci', function(done) {
|
||||
runJasmineTests(['dist/js/cjs/{angular2,benchpress}/test/**/*_spec.js'], done);
|
||||
});
|
||||
|
||||
gulp.task('check-public-api',
|
||||
function(done) { runJasmineTests(['dist/tools/public_api_guard/**/*_spec.js'], done); });
|
||||
|
||||
gulp.task('test.unit.cjs', ['build/clean.js', 'build.tools'], function(neverDone) {
|
||||
var watch = require('./tools/build/watch');
|
||||
@ -791,7 +935,7 @@ gulp.task('test.transpiler.unittest',
|
||||
// Make a temporary directory and symlink dartium from there (just for this command)
|
||||
// so that it can run.
|
||||
var dartiumTmpdir = path.join(os.tmpdir(), 'dartium' + new Date().getTime().toString());
|
||||
gulp.task('test.dart.angular2_testing/ci', ['!pubget.angular2_testing.dart'], function(done) {
|
||||
gulp.task('test.dart.angular2_testing/ci', ['build/pubspec.dart'], function(done) {
|
||||
runSequence('test.dart.angular2_testing_symlink', 'test.dart.angular2_testing',
|
||||
sequenceComplete(done));
|
||||
});
|
||||
@ -802,11 +946,8 @@ gulp.task(
|
||||
|
||||
gulp.task('test.dart.angular2_testing',
|
||||
shell.task(['PATH=$PATH:' + dartiumTmpdir + ' pub run test -p dartium'],
|
||||
{'cwd': 'modules_dart/angular2_testing'}));
|
||||
{'cwd': 'dist/dart/angular2_testing'}));
|
||||
|
||||
gulp.task(
|
||||
'!pubget.angular2_testing.dart',
|
||||
pubget.dir(gulp, gulpPlugins, {dir: 'modules_dart/angular2_testing', command: DART_SDK.PUB}));
|
||||
|
||||
// -----------------
|
||||
// Pre-test checks
|
||||
@ -840,15 +981,16 @@ gulp.task('!pre.test.typings.layoutNodeModule', ['build.js.cjs'], function() {
|
||||
.pipe(gulp.dest(path.join(tmpdir, 'node_modules')));
|
||||
});
|
||||
gulp.task('!pre.test.typings.copyTypingsSpec', function() {
|
||||
return gulp.src(['typing_spec/*.ts'], {base: 'typing_spec'}).pipe(gulp.dest(path.join(tmpdir)));
|
||||
return gulp.src(['typing_spec/*.ts'], {base: 'typing_spec'}).pipe(gulp.dest(tmpdir));
|
||||
});
|
||||
|
||||
gulp.task('test.typings',
|
||||
['!pre.test.typings.layoutNodeModule', '!pre.test.typings.copyTypingsSpec'], function() {
|
||||
var tsc = require('gulp-typescript');
|
||||
|
||||
return gulp.src([tmpdir + '/**'])
|
||||
return gulp.src([tmpdir + '/*.ts'])
|
||||
.pipe(tsc({
|
||||
target: 'ES5',
|
||||
target: 'ES6',
|
||||
module: 'commonjs',
|
||||
experimentalDecorators: true,
|
||||
noImplicitAny: true,
|
||||
@ -865,9 +1007,29 @@ gulp.task('test.typings',
|
||||
// unmodified and directory structure is preserved.
|
||||
//
|
||||
// This task is expected to be run after build/tree.dart
|
||||
gulp.task('build/pure-packages.dart', function() {
|
||||
var yaml = require('js-yaml');
|
||||
gulp.task('build/pure-packages.dart', function(done) {
|
||||
runSequence('build/pure-packages.dart/standalone', 'build/pure-packages.dart/license',
|
||||
'build/pure-packages.dart/angular2', sequenceComplete(done));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('build/pure-packages.dart/standalone', function() {
|
||||
return gulp.src([
|
||||
'modules_dart/**/*',
|
||||
'!modules_dart/**/*.proto',
|
||||
'!modules_dart/**/packages{,/**}',
|
||||
'!modules_dart/payload{,/**}',
|
||||
'!modules_dart/transform{,/**}',
|
||||
])
|
||||
.pipe(gulp.dest(CONFIG.dest.dart));
|
||||
});
|
||||
|
||||
gulp.task('build/pure-packages.dart/license', function() {
|
||||
return gulp.src(['LICENSE']).pipe(gulp.dest(path.join(CONFIG.dest.dart, 'angular2_testing')));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('build/pure-packages.dart/angular2', function() {
|
||||
return gulp.src([
|
||||
'modules_dart/transform/**/*',
|
||||
'!modules_dart/transform/**/*.proto',
|
||||
@ -932,15 +1094,19 @@ gulp.task('!build.tools', function() {
|
||||
gulp.task('broccoli.js.dev', ['build.tools'],
|
||||
function(done) { runSequence('!broccoli.js.dev', sequenceComplete(done)); });
|
||||
|
||||
gulp.task(
|
||||
'!broccoli.js.dev',
|
||||
() => angularBuilder.rebuildBrowserDevTree(
|
||||
{generateEs6: generateEs6, projects: cliArgsProjects, noTypeChecks: cliArgs.noTypeChecks}));
|
||||
gulp.task('!broccoli.js.dev', () => angularBuilder.rebuildBrowserDevTree({
|
||||
generateEs6: generateEs6,
|
||||
projects: cliArgsProjects,
|
||||
noTypeChecks: cliArgs.noTypeChecks,
|
||||
useBundles: cliArgs.useBundles
|
||||
}));
|
||||
|
||||
gulp.task(
|
||||
'!broccoli.js.prod',
|
||||
() => angularBuilder.rebuildBrowserProdTree(
|
||||
{generateEs6: generateEs6, projects: cliArgsProjects, noTypeChecks: cliArgs.noTypeChecks}));
|
||||
gulp.task('!broccoli.js.prod', () => angularBuilder.rebuildBrowserProdTree({
|
||||
generateEs6: generateEs6,
|
||||
projects: cliArgsProjects,
|
||||
noTypeChecks: cliArgs.noTypeChecks,
|
||||
useBundles: cliArgs.useBundles
|
||||
}));
|
||||
|
||||
gulp.task('build.js.dev', ['build/clean.js'], function(done) {
|
||||
runSequence('broccoli.js.dev', 'build.css.material', sequenceComplete(done));
|
||||
@ -963,9 +1129,12 @@ var firstBuildJsCjs = true;
|
||||
* private task
|
||||
*/
|
||||
gulp.task('!build.js.cjs', function() {
|
||||
return angularBuilder
|
||||
.rebuildNodeTree(
|
||||
{generateEs6: generateEs6, projects: cliArgsProjects, noTypeChecks: cliArgs.noTypeChecks})
|
||||
return angularBuilder.rebuildNodeTree({
|
||||
generateEs6: generateEs6,
|
||||
projects: cliArgsProjects,
|
||||
noTypeChecks: cliArgs.noTypeChecks,
|
||||
useBundles: cliArgs.useBundles
|
||||
})
|
||||
.then(function() {
|
||||
if (firstBuildJsCjs) {
|
||||
firstBuildJsCjs = false;
|
||||
@ -994,13 +1163,13 @@ gulp.task('!bundle.js.prod', ['build.js.prod'], function() {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
var bundlerConfig = {sourceMaps: true};
|
||||
|
||||
return bundler.bundle(bundleConfig, 'angular2/angular2', './dist/build/angular2.js',
|
||||
bundlerConfig)
|
||||
return bundler.bundle(bundleConfig, NG2_BUNDLE_CONTENT, './dist/build/angular2.js', bundlerConfig)
|
||||
.then(function() {
|
||||
return Promise.all([
|
||||
bundler.bundle(bundleConfig, 'angular2/http - angular2/core', './dist/build/http.js',
|
||||
bundler.bundle(bundleConfig, HTTP_BUNDLE_CONTENT, './dist/build/http.js', bundlerConfig),
|
||||
bundler.bundle(bundleConfig, ROUTER_BUNDLE_CONTENT, './dist/build/router.js',
|
||||
bundlerConfig),
|
||||
bundler.bundle(bundleConfig, 'angular2/router - angular2/core', './dist/build/router.js',
|
||||
bundler.bundle(bundleConfig, UPGRADE_BUNDLE_CONTENT, './dist/build/upgrade.js',
|
||||
bundlerConfig)
|
||||
]);
|
||||
});
|
||||
@ -1011,14 +1180,16 @@ gulp.task('!bundle.js.min', ['build.js.prod'], function() {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
var bundlerConfig = {sourceMaps: true, minify: true};
|
||||
|
||||
return bundler.bundle(bundleConfig, 'angular2/angular2', './dist/build/angular2.min.js',
|
||||
return bundler.bundle(bundleConfig, NG2_BUNDLE_CONTENT, './dist/build/angular2.min.js',
|
||||
bundlerConfig)
|
||||
.then(function() {
|
||||
return Promise.all([
|
||||
bundler.bundle(bundleConfig, 'angular2/http - angular2/core', './dist/build/http.min.js',
|
||||
bundler.bundle(bundleConfig, HTTP_BUNDLE_CONTENT, './dist/build/http.min.js',
|
||||
bundlerConfig),
|
||||
bundler.bundle(bundleConfig, 'angular2/router - angular2/core',
|
||||
'./dist/build/router.min.js', bundlerConfig)
|
||||
bundler.bundle(bundleConfig, ROUTER_BUNDLE_CONTENT, './dist/build/router.min.js',
|
||||
bundlerConfig),
|
||||
bundler.bundle(bundleConfig, UPGRADE_BUNDLE_CONTENT, './dist/build/upgrade.min.js',
|
||||
bundlerConfig)
|
||||
]);
|
||||
});
|
||||
});
|
||||
@ -1031,14 +1202,16 @@ gulp.task('!bundle.js.dev', ['build.js.dev'], function() {
|
||||
var devBundleConfig = merge(true, bundleConfig);
|
||||
devBundleConfig.paths = merge(true, devBundleConfig.paths, {"*": "dist/js/dev/es5/*.js"});
|
||||
|
||||
return bundler.bundle(devBundleConfig, 'angular2/angular2', './dist/build/angular2.dev.js',
|
||||
return bundler.bundle(devBundleConfig, NG2_BUNDLE_CONTENT, './dist/build/angular2.dev.js',
|
||||
bundlerConfig)
|
||||
.then(function() {
|
||||
return Promise.all([
|
||||
bundler.bundle(devBundleConfig, 'angular2/http - angular2/core',
|
||||
'./dist/build/http.dev.js', bundlerConfig),
|
||||
bundler.bundle(bundleConfig, 'angular2/router - angular2/core',
|
||||
'./dist/build/router.dev.js', bundlerConfig)
|
||||
bundler.bundle(devBundleConfig, HTTP_BUNDLE_CONTENT, './dist/build/http.dev.js',
|
||||
bundlerConfig),
|
||||
bundler.bundle(devBundleConfig, ROUTER_BUNDLE_CONTENT, './dist/build/router.dev.js',
|
||||
bundlerConfig),
|
||||
bundler.bundle(devBundleConfig, UPGRADE_BUNDLE_CONTENT, './dist/build/upgrade.dev.js',
|
||||
bundlerConfig)
|
||||
]);
|
||||
});
|
||||
});
|
||||
@ -1064,8 +1237,12 @@ gulp.task('!bundle.testing', ['build.js.dev'], function() {
|
||||
var devBundleConfig = merge(true, bundleConfig);
|
||||
devBundleConfig.paths = merge(true, devBundleConfig.paths, {"*": "dist/js/dev/es5/*.js"});
|
||||
|
||||
return bundler.bundle(devBundleConfig, 'angular2/testing - angular2/angular2',
|
||||
'./dist/js/bundle/testing.js', {sourceMaps: true});
|
||||
return bundler.bundle(devBundleConfig, TESTING_BUNDLE_CONTENT, './dist/js/bundle/testing.dev.js',
|
||||
{sourceMaps: true});
|
||||
});
|
||||
|
||||
gulp.task('!bundles.js.docs', ['clean'], function() {
|
||||
return gulp.src('modules/angular2/docs/bundles/*').pipe(gulp.dest('dist/js/bundle'));
|
||||
});
|
||||
|
||||
gulp.task('!bundles.js.umd', ['build.js.dev'], function() {
|
||||
@ -1094,13 +1271,45 @@ gulp.task('!bundles.js.umd', ['build.js.dev'], function() {
|
||||
resolve: resolveOptions(devOrProd),
|
||||
module: {preLoaders: [{test: /\.js$/, loader: 'source-map-loader'}]},
|
||||
devtool: devOrProd === 'dev' ? 'inline-source-map' : undefined,
|
||||
output: outputOptions(outFileName, devOrProd)
|
||||
output: outputOptions(outFileName, devOrProd),
|
||||
externals: {
|
||||
'rxjs/Observable': 'umd Rx',
|
||||
'rxjs/Subject': 'umd Rx',
|
||||
'rxjs/subject/ReplaySubject': {
|
||||
commonjs: 'rxjs/subject/ReplaySubject',
|
||||
commonjs2: 'rxjs/subject/ReplaySubject',
|
||||
amd: 'rxjs/subject/ReplaySubject',
|
||||
root: ['Rx']
|
||||
},
|
||||
'rxjs/operator/take': {
|
||||
commonjs: 'rxjs/operator/take',
|
||||
commonjs2: 'rxjs/operator/take',
|
||||
amd: 'rxjs/operator/take',
|
||||
root: ['Rx', 'Observable', 'prototype']
|
||||
},
|
||||
'rxjs/observable/fromPromise': {
|
||||
commonjs: 'rxjs/observable/fromPromise',
|
||||
commonjs2: 'rxjs/observable/fromPromise',
|
||||
amd: 'rxjs/observable/fromPromise',
|
||||
root: ['Rx', 'Observable']
|
||||
},
|
||||
'rxjs/operator/toPromise': {
|
||||
commonjs: 'rxjs/operator/toPromise',
|
||||
commonjs2: 'rxjs/operator/toPromise',
|
||||
amd: 'rxjs/operator/toPromise',
|
||||
root: ['Rx', 'Observable', 'prototype']
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return q.all([
|
||||
webpack(webPackConf([__dirname + '/tools/build/webpack/angular2.umd.js'], 'angular2', 'dev')),
|
||||
webpack(webPackConf([__dirname + '/tools/build/webpack/angular2.umd.js'], 'angular2', 'prod'))
|
||||
webpack(webPackConf([__dirname + '/tools/build/webpack/angular2-all.umd.js'], 'angular2-all',
|
||||
'dev')),
|
||||
webpack(webPackConf([__dirname + '/tools/build/webpack/angular2-all.umd.js'], 'angular2-all',
|
||||
'prod')),
|
||||
webpack(webPackConf([__dirname + '/tools/build/webpack/angular2-all-testing.umd.js'],
|
||||
'angular2-all-testing', 'dev'))
|
||||
]);
|
||||
});
|
||||
|
||||
@ -1109,11 +1318,7 @@ gulp.task('bundles.js.umd.min', ['!bundles.js.umd', '!bundle.ng.polyfills'], fun
|
||||
var uglify = require('gulp-uglify');
|
||||
|
||||
// minify production bundles
|
||||
return gulp.src([
|
||||
'dist/js/bundle/angular2-polyfills.js',
|
||||
'dist/js/bundle/angular2.umd.js',
|
||||
'dist/js/bundle/angular2_all.umd.js'
|
||||
])
|
||||
return gulp.src(['dist/js/bundle/angular2-polyfills.js', 'dist/js/bundle/angular2-all.umd.js'])
|
||||
.pipe(uglify())
|
||||
.pipe(rename({extname: '.min.js'}))
|
||||
.pipe(gulp.dest('dist/js/bundle'));
|
||||
@ -1122,9 +1327,10 @@ gulp.task('bundles.js.umd.min', ['!bundles.js.umd', '!bundle.ng.polyfills'], fun
|
||||
gulp.task('!bundle.js.prod.deps', ['!bundle.js.prod'], function() {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
|
||||
return merge2(addDevDependencies('angular2.js'),
|
||||
return merge2(bundler.modify(['dist/build/angular2.js'], 'angular2.js'),
|
||||
bundler.modify(['dist/build/http.js'], 'http.js'),
|
||||
bundler.modify(['dist/build/router.js'], 'router.js'))
|
||||
bundler.modify(['dist/build/router.js'], 'router.js'),
|
||||
bundler.modify(['dist/build/upgrade.js'], 'upgrade.js'))
|
||||
.pipe(gulp.dest('dist/js/bundle'));
|
||||
});
|
||||
|
||||
@ -1132,9 +1338,10 @@ gulp.task('!bundle.js.min.deps', ['!bundle.js.min'], function() {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
var uglify = require('gulp-uglify');
|
||||
|
||||
return merge2(addDevDependencies('angular2.min.js'),
|
||||
return merge2(bundler.modify(['dist/build/angular2.min.js'], 'angular2.min.js'),
|
||||
bundler.modify(['dist/build/http.min.js'], 'http.min.js'),
|
||||
bundler.modify(['dist/build/router.min.js'], 'router.min.js'))
|
||||
bundler.modify(['dist/build/router.min.js'], 'router.min.js'),
|
||||
bundler.modify(['dist/build/upgrade.min.js'], 'upgrade.min.js'))
|
||||
.pipe(uglify())
|
||||
.pipe(gulp.dest('dist/js/bundle'));
|
||||
});
|
||||
@ -1150,40 +1357,30 @@ var JS_DEV_DEPS = [
|
||||
'node_modules/reflect-metadata/Reflect.js'
|
||||
];
|
||||
|
||||
// Splice in RX license if rx is in the bundle.
|
||||
function insertRXLicense(source) {
|
||||
var n = source.indexOf('System.register("rxjs/Subject"');
|
||||
if (n >= 0) {
|
||||
// TODO: point this to Rx once Rx includes license in dist
|
||||
// https://github.com/angular/angular/issues/5558
|
||||
var rxLicense = licenseWrap('LICENSE');
|
||||
return source.slice(0, n) + rxLicense + source.slice(n);
|
||||
} else {
|
||||
return source;
|
||||
}
|
||||
}
|
||||
|
||||
function addDevDependencies(outputFile) {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
var insert = require('gulp-insert');
|
||||
|
||||
return bundler.modify(JS_DEV_DEPS.concat(['dist/build/' + outputFile]), outputFile)
|
||||
.pipe(insert.transform(insertRXLicense))
|
||||
.pipe(gulp.dest('dist/js/bundle'));
|
||||
}
|
||||
|
||||
gulp.task('!bundle.js.dev.deps', ['!bundle.js.dev'], function() {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
|
||||
return merge2(addDevDependencies('angular2.dev.js'),
|
||||
return merge2(bundler.modify(['dist/build/angular2.dev.js'], 'angular2.dev.js'),
|
||||
bundler.modify(['dist/build/http.dev.js'], 'http.dev.js'),
|
||||
bundler.modify(['dist/build/router.dev.js'], 'router.dev.js'))
|
||||
bundler.modify(['dist/build/router.dev.js'], 'router.dev.js'),
|
||||
bundler.modify(['dist/build/upgrade.dev.js'], 'upgrade.dev.js'))
|
||||
.pipe(gulp.dest('dist/js/bundle'));
|
||||
});
|
||||
|
||||
gulp.task('!bundle.web_worker.js.dev.deps', ['!bundle.web_worker.js.dev'], function() {
|
||||
return merge2(
|
||||
addDevDependencies("web_worker/ui.dev.js", addDevDependencies("web_worker/worker.dev.js")));
|
||||
var bundler = require('./tools/build/bundle');
|
||||
return merge2(bundler.modify(['dist/build/web_worker/ui.dev.js'], "web_worker/ui.dev.js"),
|
||||
bundler.modify(['dist/build/web_worker/worker.dev.js'], "web_worker/worker.dev.js"))
|
||||
.pipe(gulp.dest('dist/js/bundle'));
|
||||
});
|
||||
|
||||
gulp.task('!bundle.copy', function() {
|
||||
@ -1193,7 +1390,7 @@ gulp.task('!bundle.copy', function() {
|
||||
|
||||
gulp.task('!bundles.js.checksize', function(done) {
|
||||
var reportSize = require('./tools/analytics/reportsize');
|
||||
return reportSize('dist/js/bundle/**', {printToConsole: ['gzip level=2']});
|
||||
return reportSize('dist/js/bundle/**/*.js', {printToConsole: ['gzip level=2']});
|
||||
});
|
||||
|
||||
gulp.task('bundles.js',
|
||||
@ -1204,7 +1401,8 @@ gulp.task('bundles.js',
|
||||
'!bundle.web_worker.js.dev.deps',
|
||||
'bundles.js.umd.min',
|
||||
'!bundle.testing',
|
||||
'!bundle.ng.polyfills'
|
||||
'!bundle.ng.polyfills',
|
||||
'!bundles.js.docs'
|
||||
],
|
||||
function(done) { runSequence('!bundle.copy', '!bundles.js.checksize', done); });
|
||||
|
||||
@ -1216,7 +1414,7 @@ gulp.task('clean', [
|
||||
'build/clean.js',
|
||||
'build/clean.dart',
|
||||
'build/clean.docs',
|
||||
'build/clean.benchpress.bundle'
|
||||
'build/clean.bundles'
|
||||
]);
|
||||
|
||||
gulp.task('build', ['build.js', 'build.dart']);
|
||||
@ -1307,7 +1505,7 @@ gulp.task('build.dart.material', ['build/packages.dart'], function(done) {
|
||||
|
||||
gulp.task('cleanup.builder', function() { return angularBuilder.cleanup(); });
|
||||
|
||||
gulp.task('benchpress.bundle', ['build/clean.benchpress.bundle', 'build.js.cjs'], function(cb) {
|
||||
gulp.task('benchpress.bundle', ['build/clean.bundles.benchpress', 'build.js.cjs'], function(cb) {
|
||||
var bundler = require('./tools/build/bundle');
|
||||
|
||||
bundler.benchpressBundle(BENCHPRESS_BUNDLE_CONFIG.entries, BENCHPRESS_BUNDLE_CONFIG.packageJson,
|
||||
|
@ -79,7 +79,7 @@ module.exports = function(config) {
|
||||
|
||||
if (process.env.TRAVIS) {
|
||||
var buildId = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')';
|
||||
if (process.env.MODE === 'saucelabs') {
|
||||
if (process.env.MODE.startsWith('saucelabs')) {
|
||||
config.sauceLabs.build = buildId;
|
||||
config.sauceLabs.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
|
||||
|
||||
@ -89,7 +89,7 @@ module.exports = function(config) {
|
||||
config.transports = ['polling'];
|
||||
}
|
||||
|
||||
if (process.env.MODE === 'browserstack') {
|
||||
if (process.env.MODE.startsWith('browserstack')) {
|
||||
config.browserStack.build = buildId;
|
||||
config.browserStack.tunnelIdentifier = process.env.TRAVIS_JOB_NUMBER;
|
||||
}
|
||||
|
50
modules/angular1_router/build.js
vendored
50
modules/angular1_router/build.js
vendored
@ -21,18 +21,25 @@ var files = [
|
||||
|
||||
var PRELUDE = '(function(){\n';
|
||||
var POSTLUDE = '\n}());\n';
|
||||
var FACADES = fs.readFileSync(__dirname + '/lib/facades.es5', 'utf8');
|
||||
var DIRECTIVES = fs.readFileSync(__dirname + '/src/ng_outlet.ts', 'utf8');
|
||||
var moduleTemplate = fs.readFileSync(__dirname + '/src/module_template.js', 'utf8');
|
||||
|
||||
function main() {
|
||||
var dir = __dirname + '/../angular2/src/router/';
|
||||
function main(modulesDirectory) {
|
||||
var angular1RouterModuleDirectory = modulesDirectory + '/angular1_router';
|
||||
|
||||
var facades = fs.readFileSync(
|
||||
angular1RouterModuleDirectory + '/lib/facades.es5', 'utf8');
|
||||
var directives = fs.readFileSync(
|
||||
angular1RouterModuleDirectory + '/src/ng_outlet.ts', 'utf8');
|
||||
var moduleTemplate = fs.readFileSync(
|
||||
angular1RouterModuleDirectory + '/src/module_template.js', 'utf8');
|
||||
|
||||
var dir = modulesDirectory + '/angular2/src/router/';
|
||||
var sharedCode = files.reduce(function (prev, file) {
|
||||
return prev + transform(fs.readFileSync(dir + file, 'utf8'));
|
||||
}, '');
|
||||
|
||||
var out = moduleTemplate.replace('//{{FACADES}}', FACADES).replace('//{{SHARED_CODE}}', sharedCode);
|
||||
return PRELUDE + transform(DIRECTIVES) + out + POSTLUDE;
|
||||
var out = moduleTemplate.replace('//{{FACADES}}', facades)
|
||||
.replace('//{{SHARED_CODE}}', sharedCode);
|
||||
return PRELUDE + transform(directives) + out + POSTLUDE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -62,10 +69,29 @@ function isFacadeModule(modulePath) {
|
||||
modulePath === 'angular2/src/core/reflection/reflection';
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
var dist = __dirname + '/../../dist';
|
||||
if (!fs.existsSync(dist)) {
|
||||
fs.mkdirSync(dist);
|
||||
module.exports = function(modulesDirectory, outputDirectory) {
|
||||
if (!fs.existsSync(outputDirectory)) {
|
||||
fs.mkdirSync(outputDirectory);
|
||||
}
|
||||
fs.writeFileSync(dist + '/angular_1_router.js', main());
|
||||
fs.writeFileSync(
|
||||
outputDirectory + '/angular_1_router.js', main(modulesDirectory));
|
||||
};
|
||||
|
||||
// CLI entry point
|
||||
if (require.main === module) {
|
||||
try {
|
||||
var args = process.argv;
|
||||
args.shift(); // node
|
||||
args.shift(); // scriptfile.js
|
||||
if (args.length < 2) {
|
||||
console.log("usage: $0 outFile path/to/modules");
|
||||
process.exit(1);
|
||||
}
|
||||
var outfile = args.shift();
|
||||
var directory = args.shift();
|
||||
fs.writeFileSync(outfile, main(directory));
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -173,6 +173,10 @@ var StringMapWrapper = {
|
||||
|
||||
var List = Array;
|
||||
var ListWrapper = {
|
||||
toJSON: function(l) {
|
||||
return JSON.stringify(l);
|
||||
},
|
||||
|
||||
clear: function (l) {
|
||||
l.length = 0;
|
||||
},
|
||||
@ -195,6 +199,10 @@ var ListWrapper = {
|
||||
return array[0];
|
||||
},
|
||||
|
||||
last: function(array) {
|
||||
return (array && array.length) > 0 ? array[array.length - 1] : null;
|
||||
},
|
||||
|
||||
map: function (l, fn) {
|
||||
return l.map(fn);
|
||||
},
|
||||
@ -243,6 +251,10 @@ var ListWrapper = {
|
||||
};
|
||||
|
||||
var StringWrapper = {
|
||||
charCodeAt: function(s, i) {
|
||||
return s.charCodeAt(i);
|
||||
},
|
||||
|
||||
equals: function (s1, s2) {
|
||||
return s1 === s2;
|
||||
},
|
||||
@ -299,8 +311,8 @@ Location.prototype.subscribe = function () {
|
||||
//TODO: implement
|
||||
};
|
||||
Location.prototype.path = function () {
|
||||
return $location.path();
|
||||
return $location.url();
|
||||
};
|
||||
Location.prototype.go = function (url) {
|
||||
return $location.path(url);
|
||||
Location.prototype.go = function (path, query) {
|
||||
return $location.url(path + query);
|
||||
};
|
||||
|
@ -57,7 +57,7 @@ function routerFactory($q, $location, $$directiveIntrospector, $browser, $rootSc
|
||||
});
|
||||
|
||||
var router = new RootRouter(registry, location, $routerRootComponent);
|
||||
$rootScope.$watch(function () { return $location.path(); }, function (path) {
|
||||
$rootScope.$watch(function () { return $location.url(); }, function (path) {
|
||||
if (router.lastNavigationAttempt !== path) {
|
||||
router.navigateByUrl(path);
|
||||
}
|
||||
|
@ -155,10 +155,12 @@ function ngOutletDirective($animate, $q: ng.IQService, $router) {
|
||||
}
|
||||
|
||||
this.controller.$$routeParams = instruction.params;
|
||||
this.controller.$$template = '<div ' + dashCase(componentName) + '></div>';
|
||||
this.controller.$$template =
|
||||
'<' + dashCase(componentName) + ' router="$$router"></' + dashCase(componentName) + '>';
|
||||
this.controller.$$router = this.router.childRouter(instruction.componentType);
|
||||
|
||||
let newScope = scope.$new();
|
||||
newScope.$$router = this.controller.$$router;
|
||||
|
||||
let clone = $transclude(newScope, clone => {
|
||||
$animate.enter(clone, null, this.currentElement || element);
|
||||
@ -285,13 +287,13 @@ function dashCase(str: string): string {
|
||||
* A module for adding new a routing system Angular 1.
|
||||
*/
|
||||
angular.module('ngComponentRouter', [])
|
||||
.directive('ngOutlet', ngOutletDirective)
|
||||
.directive('ngOutlet', ngOutletFillContentDirective)
|
||||
.directive('ngLink', ngLinkDirective);
|
||||
.directive('ngOutlet', ['$animate', '$q', '$router', ngOutletDirective])
|
||||
.directive('ngOutlet', ['$compile', ngOutletFillContentDirective])
|
||||
.directive('ngLink', ['$router', '$parse', ngLinkDirective]);
|
||||
|
||||
/*
|
||||
* A module for inspecting controller constructors
|
||||
*/
|
||||
angular.module('ng')
|
||||
.provider('$$directiveIntrospector', DirectiveIntrospectorProvider)
|
||||
.config(compilerProviderDecorator);
|
||||
.config(['$compileProvider', '$$directiveIntrospectorProvider', compilerProviderDecorator]);
|
||||
|
2
modules/angular1_router/src/ng_route_shim.js
vendored
2
modules/angular1_router/src/ng_route_shim.js
vendored
@ -1,4 +1,4 @@
|
||||
/** @license Copyright 2014-2015 Google, Inc. http://github.com/angular/angular/LICENSE */
|
||||
/** @license Copyright 2014-2016 Google, Inc. http://github.com/angular/angular/LICENSE */
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
@ -21,17 +21,29 @@ describe('navigation', function () {
|
||||
$router = _$router_;
|
||||
});
|
||||
|
||||
registerComponent('userCmp', {
|
||||
registerDirective('userCmp', {
|
||||
template: '<div>hello {{userCmp.$routeParams.name}}</div>'
|
||||
});
|
||||
registerComponent('oneCmp', {
|
||||
registerDirective('oneCmp', {
|
||||
template: '<div>{{oneCmp.number}}</div>',
|
||||
controller: function () {this.number = 'one'}
|
||||
});
|
||||
registerComponent('twoCmp', {
|
||||
registerDirective('twoCmp', {
|
||||
template: '<div>{{twoCmp.number}}</div>',
|
||||
controller: function () {this.number = 'two'}
|
||||
});
|
||||
registerComponent('threeCmp', {
|
||||
template: '<div>{{$ctrl.number}}</div>',
|
||||
controller: function () {this.number = 'three'}
|
||||
});
|
||||
registerComponent('getParams', {
|
||||
template: '<div>{{$ctrl.params.x}}</div>',
|
||||
controller: function () {
|
||||
this.$routerOnActivate = function(next) {
|
||||
this.params = next.params;
|
||||
};
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('should work in a simple case', function () {
|
||||
@ -47,6 +59,21 @@ describe('navigation', function () {
|
||||
expect(elt.text()).toBe('one');
|
||||
});
|
||||
|
||||
|
||||
it('should work with components created by the `mod.component()` helper', function () {
|
||||
compile('<ng-outlet></ng-outlet>');
|
||||
|
||||
$router.config([
|
||||
{ path: '/', component: 'threeCmp' }
|
||||
]);
|
||||
|
||||
$router.navigateByUrl('/');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(elt.text()).toBe('three');
|
||||
});
|
||||
|
||||
|
||||
it('should navigate between components with different parameters', function () {
|
||||
$router.config([
|
||||
{ path: '/user/:name', component: 'userCmp' }
|
||||
@ -68,7 +95,7 @@ describe('navigation', function () {
|
||||
function ParentController() {
|
||||
instanceCount += 1;
|
||||
}
|
||||
registerComponent('parentCmp', {
|
||||
registerDirective('parentCmp', {
|
||||
template: 'parent { <ng-outlet></ng-outlet> }',
|
||||
$routeConfig: [
|
||||
{ path: '/user/:name', component: 'userCmp' }
|
||||
@ -94,7 +121,7 @@ describe('navigation', function () {
|
||||
|
||||
|
||||
it('should work with nested outlets', function () {
|
||||
registerComponent('childCmp', {
|
||||
registerDirective('childCmp', {
|
||||
template: '<div>inner { <div ng-outlet></div> }</div>',
|
||||
$routeConfig: [
|
||||
{ path: '/b', component: 'oneCmp' }
|
||||
@ -112,9 +139,29 @@ describe('navigation', function () {
|
||||
expect(elt.text()).toBe('outer { inner { one } }');
|
||||
});
|
||||
|
||||
it('should work when parent route has empty path', inject(function ($location) {
|
||||
registerComponent('childCmp', {
|
||||
template: '<div>inner { <div ng-outlet></div> }</div>',
|
||||
$routeConfig: [
|
||||
{ path: '/b', component: 'oneCmp' }
|
||||
]
|
||||
});
|
||||
|
||||
$router.config([
|
||||
{ path: '/...', component: 'childCmp' }
|
||||
]);
|
||||
compile('<div>outer { <div ng-outlet></div> }</div>');
|
||||
|
||||
$router.navigateByUrl('/b');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(elt.text()).toBe('outer { inner { one } }');
|
||||
expect($location.path()).toBe('/b');
|
||||
}));
|
||||
|
||||
|
||||
it('should work with recursive nested outlets', function () {
|
||||
registerComponent('recurCmp', {
|
||||
registerDirective('recurCmp', {
|
||||
template: '<div>recur { <div ng-outlet></div> }</div>',
|
||||
$routeConfig: [
|
||||
{ path: '/recur', component: 'recurCmp' },
|
||||
@ -147,6 +194,21 @@ describe('navigation', function () {
|
||||
}));
|
||||
|
||||
|
||||
it('should pass through query terms to the location', inject(function ($location) {
|
||||
$router.config([
|
||||
{ path: '/user', component: 'userCmp' }
|
||||
]);
|
||||
|
||||
compile('<div ng-outlet></div>');
|
||||
|
||||
$router.navigateByUrl('/user?x=y');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect($location.path()).toBe('/user');
|
||||
expect($location.search()).toEqual({ x: 'y'});
|
||||
}));
|
||||
|
||||
|
||||
it('should change location to the canonical route', inject(function ($location) {
|
||||
compile('<div ng-outlet></div>');
|
||||
|
||||
@ -163,7 +225,7 @@ describe('navigation', function () {
|
||||
|
||||
|
||||
it('should change location to the canonical route with nested components', inject(function ($location) {
|
||||
registerComponent('childRouter', {
|
||||
registerDirective('childRouter', {
|
||||
template: '<div>inner { <div ng-outlet></div> }</div>',
|
||||
$routeConfig: [
|
||||
{ path: '/new-child', component: 'oneCmp', name: 'NewChild'},
|
||||
@ -206,9 +268,22 @@ describe('navigation', function () {
|
||||
}));
|
||||
|
||||
|
||||
it('should navigate when the location query changes', inject(function ($location) {
|
||||
$router.config([
|
||||
{ path: '/get/params', component: 'getParams' }
|
||||
]);
|
||||
compile('<div ng-outlet></div>');
|
||||
|
||||
$location.url('/get/params?x=y');
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(elt.text()).toBe('y');
|
||||
}));
|
||||
|
||||
|
||||
it('should expose a "navigating" property on $router', inject(function ($q) {
|
||||
var defer;
|
||||
registerComponent('pendingActivate', {
|
||||
registerDirective('pendingActivate', {
|
||||
$canActivate: function () {
|
||||
defer = $q.defer();
|
||||
return defer.promise;
|
||||
@ -227,36 +302,54 @@ describe('navigation', function () {
|
||||
expect($router.navigating).toBe(false);
|
||||
}));
|
||||
|
||||
function registerComponent(name, options) {
|
||||
var controller = options.controller || function () {};
|
||||
|
||||
['$routerOnActivate', '$routerOnDeactivate', '$routerOnReuse', '$routerCanReuse', '$routerCanDeactivate'].forEach(function (hookName) {
|
||||
if (options[hookName]) {
|
||||
controller.prototype[hookName] = options[hookName];
|
||||
}
|
||||
});
|
||||
|
||||
function registerDirective(name, options) {
|
||||
function factory() {
|
||||
return {
|
||||
template: options.template || '',
|
||||
controllerAs: name,
|
||||
controller: controller
|
||||
controller: getController(options)
|
||||
};
|
||||
}
|
||||
|
||||
if (options.$canActivate) {
|
||||
factory.$canActivate = options.$canActivate;
|
||||
}
|
||||
if (options.$routeConfig) {
|
||||
factory.$routeConfig = options.$routeConfig;
|
||||
}
|
||||
|
||||
applyStaticProperties(factory, options);
|
||||
$compileProvider.directive(name, factory);
|
||||
}
|
||||
|
||||
function registerComponent(name, options) {
|
||||
|
||||
var definition = {
|
||||
template: options.template || '',
|
||||
controller: getController(options),
|
||||
}
|
||||
applyStaticProperties(definition, options);
|
||||
$compileProvider.component(name, definition);
|
||||
}
|
||||
|
||||
function compile(template) {
|
||||
elt = $compile('<div>' + template + '</div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
return elt;
|
||||
}
|
||||
|
||||
function getController(options) {
|
||||
var controller = options.controller || function () {};
|
||||
[
|
||||
'$routerOnActivate', '$routerOnDeactivate',
|
||||
'$routerOnReuse', '$routerCanReuse',
|
||||
'$routerCanDeactivate'
|
||||
].forEach(function (hookName) {
|
||||
if (options[hookName]) {
|
||||
controller.prototype[hookName] = options[hookName];
|
||||
}
|
||||
});
|
||||
return controller;
|
||||
}
|
||||
|
||||
function applyStaticProperties(target, options) {
|
||||
['$canActivate', '$routeConfig'].forEach(function(property) {
|
||||
if (options[property]) {
|
||||
target[property] = options[property];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -44,36 +44,105 @@ describe('router', function () {
|
||||
expect(elt.text()).toBe('Home');
|
||||
}));
|
||||
|
||||
function registerComponent(name, options) {
|
||||
var controller = options.controller || function () {};
|
||||
it('should bind the component to the current router', inject(function($location) {
|
||||
var router;
|
||||
registerComponent('homeCmp', {
|
||||
bindings: { router: '=' },
|
||||
controller: function($scope, $element) {
|
||||
this.$routerOnActivate = function() {
|
||||
router = this.router;
|
||||
};
|
||||
},
|
||||
template: 'Home'
|
||||
});
|
||||
|
||||
['$onActivate', '$onDeactivate', '$onReuse', '$canReuse', '$canDeactivate'].forEach(function (hookName) {
|
||||
if (options[hookName]) {
|
||||
controller.prototype[hookName] = options[hookName];
|
||||
registerComponent('app', {
|
||||
template: '<div ng-outlet></div>',
|
||||
$routeConfig: [
|
||||
{ path: '/', component: 'homeCmp' }
|
||||
]
|
||||
});
|
||||
|
||||
compile('<app></app>');
|
||||
|
||||
$location.path('/');
|
||||
$rootScope.$digest();
|
||||
var homeElement = elt.find('home-cmp');
|
||||
expect(homeElement.text()).toBe('Home');
|
||||
expect(homeElement.isolateScope().$ctrl.router).toBeDefined();
|
||||
expect(router).toBeDefined();
|
||||
}));
|
||||
|
||||
it('should work when an async route is provided route data', inject(function($location, $q) {
|
||||
registerDirective('homeCmp', {
|
||||
template: 'Home ({{homeCmp.isAdmin}})',
|
||||
$routerOnActivate: function(next, prev) {
|
||||
this.isAdmin = next.routeData.data.isAdmin;
|
||||
}
|
||||
});
|
||||
|
||||
registerDirective('app', {
|
||||
template: '<div ng-outlet></div>',
|
||||
$routeConfig: [
|
||||
{ path: '/', loader: function() { return $q.when('homeCmp'); }, data: { isAdmin: true } }
|
||||
]
|
||||
});
|
||||
|
||||
compile('<app></app>');
|
||||
|
||||
$location.path('/');
|
||||
$rootScope.$digest();
|
||||
expect(elt.text()).toBe('Home (true)');
|
||||
}));
|
||||
|
||||
function registerDirective(name, options) {
|
||||
function factory() {
|
||||
return {
|
||||
template: options.template || '',
|
||||
controllerAs: name,
|
||||
controller: controller
|
||||
controller: getController(options)
|
||||
};
|
||||
}
|
||||
|
||||
if (options.$canActivate) {
|
||||
factory.$canActivate = options.$canActivate;
|
||||
}
|
||||
if (options.$routeConfig) {
|
||||
factory.$routeConfig = options.$routeConfig;
|
||||
}
|
||||
|
||||
applyStaticProperties(factory, options);
|
||||
$compileProvider.directive(name, factory);
|
||||
}
|
||||
|
||||
function registerComponent(name, options) {
|
||||
|
||||
var definition = {
|
||||
bindings: options.bindings,
|
||||
template: options.template || '',
|
||||
controller: getController(options),
|
||||
}
|
||||
applyStaticProperties(definition, options);
|
||||
$compileProvider.component(name, definition);
|
||||
}
|
||||
|
||||
function compile(template) {
|
||||
elt = $compile('<div>' + template + '</div>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
return elt;
|
||||
}
|
||||
|
||||
function getController(options) {
|
||||
var controller = options.controller || function () {};
|
||||
[
|
||||
'$routerOnActivate', '$routerOnDeactivate',
|
||||
'$routerOnReuse', '$routerCanReuse',
|
||||
'$routerCanDeactivate'
|
||||
].forEach(function (hookName) {
|
||||
if (options[hookName]) {
|
||||
controller.prototype[hookName] = options[hookName];
|
||||
}
|
||||
});
|
||||
return controller;
|
||||
}
|
||||
|
||||
function applyStaticProperties(target, options) {
|
||||
['$canActivate', '$routeConfig'].forEach(function(property) {
|
||||
if (options[property]) {
|
||||
target[property] = options[property];
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
"version": "v4",
|
||||
"repo": "angular/DefinitelyTyped",
|
||||
"repo": "DefinitelyTyped/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"angularjs/angular.d.ts": {
|
||||
"commit": "746b9a892629060bc853e792afff536e0ec4655e"
|
||||
"commit": "6eebd5e90a1cbd6b47b0705ba72dbcd5baf846f3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,7 @@ library angular2;
|
||||
*
|
||||
* This library does not include `bootstrap`. Import `bootstrap.dart` instead.
|
||||
*/
|
||||
export 'package:angular2/core.dart'
|
||||
hide forwardRef, resolveForwardRef, ForwardRefFn;
|
||||
export 'package:angular2/core.dart';
|
||||
export 'package:angular2/common.dart';
|
||||
export 'package:angular2/instrumentation.dart';
|
||||
export 'package:angular2/src/core/angular_entrypoint.dart' show AngularEntrypoint;
|
||||
@ -16,4 +15,3 @@ export 'package:angular2/src/platform/dom/dom_tokens.dart';
|
||||
export 'package:angular2/src/platform/dom/dom_adapter.dart';
|
||||
export 'package:angular2/src/platform/dom/events/event_manager.dart';
|
||||
export 'package:angular2/src/compiler/url_resolver.dart';
|
||||
export 'package:angular2/src/compiler/app_root_url.dart';
|
||||
|
@ -1,8 +0,0 @@
|
||||
export * from './common';
|
||||
export * from './core';
|
||||
export * from './instrumentation';
|
||||
export * from './platform/browser';
|
||||
export * from './src/platform/dom/dom_adapter';
|
||||
export * from './src/platform/dom/events/event_manager';
|
||||
export * from './upgrade';
|
||||
export {UrlResolver, AppRootUrl} from './compiler';
|
@ -5,5 +5,4 @@
|
||||
*/
|
||||
export * from './src/compiler/url_resolver';
|
||||
export * from './src/compiler/xhr';
|
||||
export * from './src/compiler/compiler';
|
||||
export * from './src/compiler/app_root_url';
|
||||
export * from './src/compiler/compiler';
|
26
modules/angular2/core.dart
Normal file
26
modules/angular2/core.dart
Normal file
@ -0,0 +1,26 @@
|
||||
library angular2.core;
|
||||
|
||||
export './src/core/angular_entrypoint.dart' show AngularEntrypoint;
|
||||
export './src/core/metadata.dart';
|
||||
export './src/core/util.dart';
|
||||
export 'package:angular2/src/facade/lang.dart' show enableProdMode;
|
||||
export './src/core/di.dart' hide ForwardRefFn, resolveForwardRef, forwardRef;
|
||||
export './src/facade/facade.dart';
|
||||
export './src/core/application_ref.dart' show platform, createNgZone, PlatformRef, ApplicationRef;
|
||||
export './src/core/application_tokens.dart' show APP_ID,
|
||||
APP_COMPONENT,
|
||||
APP_INITIALIZER,
|
||||
PACKAGE_ROOT_URL,
|
||||
PLATFORM_INITIALIZER;
|
||||
export './src/core/zone.dart';
|
||||
export './src/core/render.dart';
|
||||
export './src/core/linker.dart';
|
||||
export './src/core/debug/debug_node.dart' show DebugElement,
|
||||
DebugNode,
|
||||
asNativeElements;
|
||||
export './src/core/testability/testability.dart';
|
||||
export './src/core/change_detection.dart';
|
||||
export './src/core/platform_directives_and_pipes.dart';
|
||||
export './src/core/platform_common_providers.dart';
|
||||
export './src/core/application_common_providers.dart';
|
||||
export './src/core/reflection/reflection.dart';
|
@ -5,28 +5,25 @@
|
||||
*/
|
||||
export * from './src/core/metadata';
|
||||
export * from './src/core/util';
|
||||
export * from './src/core/dev_mode';
|
||||
export * from './src/core/prod_mode';
|
||||
export * from './src/core/di';
|
||||
export * from './src/facade/facade';
|
||||
export {enableProdMode} from 'angular2/src/facade/lang';
|
||||
export {platform, createNgZone, PlatformRef, ApplicationRef} from './src/core/application_ref';
|
||||
export {
|
||||
APP_ID,
|
||||
APP_COMPONENT,
|
||||
APP_INITIALIZER,
|
||||
PACKAGE_ROOT_URL,
|
||||
PLATFORM_INITIALIZER
|
||||
} from './src/core/application_tokens';
|
||||
export * from './src/core/zone';
|
||||
export * from './src/core/render';
|
||||
export * from './src/core/linker';
|
||||
export {
|
||||
DebugElement,
|
||||
Scope,
|
||||
inspectElement,
|
||||
asNativeElements
|
||||
} from './src/core/debug/debug_element';
|
||||
export {DebugElement, DebugNode, asNativeElements} from './src/core/debug/debug_node';
|
||||
export * from './src/core/testability/testability';
|
||||
export * from './src/core/change_detection';
|
||||
export * from './src/core/platform_directives_and_pipes';
|
||||
export * from './src/core/platform_common_providers';
|
||||
export * from './src/core/application_common_providers';
|
||||
export * from './src/core/reflection/reflection';
|
||||
export * from './src/core/reflection/reflection';
|
||||
|
92
modules/angular2/docs/bundles/overview.md
Normal file
92
modules/angular2/docs/bundles/overview.md
Normal file
@ -0,0 +1,92 @@
|
||||
# TL;DR;
|
||||
|
||||
* If you write ES5 use _one_ of the `UMD` bundles.
|
||||
* If you experiment with Angular2 using online prototyping tools like [plnkr](http://plnkr.co/) or similar use `System.register` bundles with SystemJS loader.
|
||||
* If you use build tools like Browserify or WebPack - bundle Angular2 as part of your build.
|
||||
* For all the above cases you must use `angular2-polyfills.js` in a `script` tag to easily include polyfills and external dependencies.
|
||||
|
||||
# Modules, barrels and bundles
|
||||
|
||||
Angular2 source code is authored using the ES2015 standardized module format where one module corresponds to exactly one file. Multiple modules (files) can be logically grouped into so-called "barrels".
|
||||
A bundle is a file that contains all the code for one or more barrels.
|
||||
|
||||
Most bundles come in several flavors:
|
||||
* regular and minified (got `.min` in their name);
|
||||
* regular and "development" (have `.dev` in their name) - "development" bundles contain in-line source maps and don't have minified flavor (minification removes in-lined source maps).
|
||||
|
||||
# Bundles, their content and usage scenarios
|
||||
|
||||
Angular 2 distributes several types of bundles targeted at specific usages:
|
||||
* users writing ES5 code without any transpilation steps
|
||||
* users experimenting with Angular 2 and TypeScript/ES2015 using online tools like plunker, jsbin or similar
|
||||
|
||||
Since each identified scenario has slightly different requirements and constraints there are specific bundles for each use-case.
|
||||
|
||||
## ES5 and ngUpgrade users
|
||||
|
||||
ES5 users and AngularJS 1.x users interested in the `ngUpgrade` path can take advantage of the bundles in the [UMD format](https://github.com/umdjs/umd).
|
||||
Those are coarse-grained bundles that combine many barrels in one final file.
|
||||
|
||||
filename | list of barrels | dev/prod | minified?
|
||||
------------|-------------------|----------|-------------|--------------|-------------
|
||||
`angular2-all.umd.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade`| prod | no
|
||||
`angular2-all.umd.min.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade` | prod | yes
|
||||
`angular2-all.umd.dev.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade` | dev | no
|
||||
`angular2-all-testing.umd.dev.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade`, `angular2/testing`, `angular2/http/testing`, `angular2/router/testing`, `angular2/platform/testing/browser` | dev | no
|
||||
|
||||
**Warning**: bundles in the `UMD` format are _not_ "additive". A single application should use only one bundle from the above list.
|
||||
|
||||
## SystemJS loader users
|
||||
|
||||
[SystemJS loader](https://github.com/systemjs/systemjs) with on-the-fly (in a browser) transpilations support is very useful for quick experiments using tools like plunker, jsbin or similar.
|
||||
For this scenario Angular 2 is distributed with bundles in the [System.register format](https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained):
|
||||
|
||||
filename | list of barrels | dev/prod | minified?
|
||||
------------|-------------------|----------|-------------|--------------|-------------
|
||||
`angular2.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/instrumentation`| prod | no
|
||||
`angular2.min.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/instrumentation`| prod | yes
|
||||
`angular2.dev.js` | `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/instrumentation`| dev | no
|
||||
`http.js` | `angular2/http` | prod | no
|
||||
`http.min.js` | `angular2/http` | prod | yes
|
||||
`http.dev.js` | `angular2/http` | dev | no
|
||||
`router.js` | `angular2/router` | prod | no
|
||||
`router.min.js` | `angular2/router` | prod | yes
|
||||
`router.dev.js` | `angular2/router` | dev | no
|
||||
`upgrade.js` | `angular2/upgrade` | prod | no
|
||||
`upgrade.min.js` | `angular2/upgrade` | prod | yes
|
||||
`upgrade.dev.js` | `angular2/upgrade` | dev | no
|
||||
`testing.dev.js` | `angular2/testing`, `angular2/http/testing`, `angular2/router/testing`, `angular2/platform/testing/browser` | dev | no
|
||||
|
||||
**Note**: bundles in the `System.register` format are "additive" - it is quite common to include several bundles in one application.
|
||||
For example people using Angular 2 with `http` and `router` would include: `angular2.js`, `http.js` and `router.js`.
|
||||
|
||||
## Browserify / JSPM / Rollup / WebPack users
|
||||
|
||||
Angular 2 doesn't provide any bundles for use with packaging tools Browserify or WebPack. Those tools are sophisticated enough to build optimal bundles for production use from individual Angular 2 files distributed in the npm package.
|
||||
An example of an Angular 2 project built with WebPack can be found in the [angular2-seed](https://github.com/angular/angular2-seed) repository.
|
||||
|
||||
|
||||
# Polyfills and external dependencies
|
||||
|
||||
## Required Polyfills
|
||||
|
||||
Polyfills are required for Angular 2 to function properly (the exact list depends on the browser used) and external dependencies ([zone.js](https://github.com/angular/zone.js)).
|
||||
To ease setup of Angular 2 applications there is one file - `angular2-polyfills.js` - that combines:
|
||||
* a pollyfill mandatory for all browsers: [reflect-metadata](https://www.npmjs.com/package/reflect-metadata)
|
||||
* [zone.js](https://github.com/angular/zone.js)
|
||||
|
||||
**Note**: `angular2-polyfills.js` contains code that should be loaded into the browser as the very first code of the web application even before the module loader. The preferred solution is to load the mentioned file in a `script` tag as early as possible.
|
||||
|
||||
|
||||
## RxJS
|
||||
|
||||
[RxJS](https://github.com/ReactiveX/RxJS) is a required dependency of Angular 2.
|
||||
|
||||
You should include RxJS in your project by declaring a dependency on the [`rxjs` npm package](https://www.npmjs.com/package/rxjs).
|
||||
|
||||
Depending on if you are using Angular bundles or not you can either use RxJS bundles from `node_modules/rxjs/bundles/` or configure your bundler to pull in the individual files from the npm package.
|
||||
|
||||
|
||||
## ES6 shims (optional)
|
||||
|
||||
Users of pre-ES6 browsers might need to add an ES6 shim (e.g. [es6-shim](https://github.com/paulmillr/es6-shim))
|
@ -2,8 +2,17 @@
|
||||
Bootstrapping
|
||||
@cheatsheetIndex 0
|
||||
@description
|
||||
`import {bootstrap} from 'angular2/angular2';`
|
||||
{@target ts}`import {bootstrap} from 'angular2/platform/browser';`{@endtarget}
|
||||
{@target js}Available from the `ng.platform.browser` namespace{@endtarget}
|
||||
{@target dart}`import 'package:angular2/bootstrap.dart';`{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
`bootstrap(MyAppComponent, [MyService, provide(...)]);`
|
||||
Bootstraps an application with MyAppComponent as the root component and configures the DI providers.
|
||||
syntax(ts dart):
|
||||
`bootstrap(MyAppComponent, [MyService, provide(...)]);`|`provide`
|
||||
syntax(js):
|
||||
`document.addEventListener('DOMContentLoaded', function () {
|
||||
ng.platform.browser.bootstrap(MyAppComponent,
|
||||
[MyService, ng.core.provide(...)]);
|
||||
});`|`provide`
|
||||
description:
|
||||
Bootstraps an application with MyAppComponent as the root component and configures the DI providers. {@target js}Must be wrapped in the event listener to fire when the page loads.{@endtarget}
|
||||
|
@ -2,24 +2,34 @@
|
||||
Built-in directives
|
||||
@cheatsheetIndex 2
|
||||
@description
|
||||
`import {NgIf, ...} from 'angular2/angular2';`
|
||||
{@target ts}`import {NgIf, ...} from 'angular2/common';`{@endtarget}
|
||||
{@target js}Available from the `ng.common` namespace{@endtarget}
|
||||
{@target dart}Available using `platform_directives` in pubspec{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
`<section *ng-if="showSection">`|`*ng-if`
|
||||
syntax:
|
||||
`<section *ngIf="showSection">`|`*ngIf`
|
||||
description:
|
||||
Removes or recreates a portion of the DOM tree based on the showSection expression.
|
||||
|
||||
@cheatsheetItem
|
||||
`<li *ng-for="#item of list">`|`*ng-for`
|
||||
syntax:
|
||||
`<li *ngFor="#item of list">`|`*ngFor`
|
||||
description:
|
||||
Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list.
|
||||
|
||||
@cheatsheetItem
|
||||
`<div [ng-switch]="conditionExpression">
|
||||
<template [ng-switch-when]="case1Exp">...</template>
|
||||
<template ng-switch-when="case2LiteralString">...</template>
|
||||
<template ng-switch-default>...</template>
|
||||
</div>`|`[ng-switch]`|`[ng-switch-when]`|`ng-switch-when`|`ng-switch-default`
|
||||
syntax:
|
||||
`<div [ngSwitch]="conditionExpression">
|
||||
<template [ngSwitchWhen]="case1Exp">...</template>
|
||||
<template ngSwitchWhen="case2LiteralString">...</template>
|
||||
<template ngSwitchDefault>...</template>
|
||||
</div>`|`[ngSwitch]`|`[ngSwitchWhen]`|`ngSwitchWhen`|`ngSwitchDefault`
|
||||
description:
|
||||
Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of conditionExpression.
|
||||
|
||||
@cheatsheetItem
|
||||
`<div [ng-class]="{active: isActive, disabled: isDisabled}">`|`[ng-class]`
|
||||
Binds the presence of css classes on the element to the truthiness of the associated map values. The right-hand side expression should return {class-name: true/false} map.
|
||||
syntax:
|
||||
`<div [ngClass]="{active: isActive, disabled: isDisabled}">`|`[ngClass]`
|
||||
description:
|
||||
Binds the presence of CSS classes on the element to the truthiness of the associated map values. The right-hand side expression should return {class-name: true/false} map.
|
||||
|
@ -2,20 +2,47 @@
|
||||
Class decorators
|
||||
@cheatsheetIndex 4
|
||||
@description
|
||||
`import {Directive, ...} from 'angular2/angular2';`
|
||||
{@target ts}`import {Directive, ...} from 'angular2/core';`{@endtarget}
|
||||
{@target js}Available from the `ng.core` namespace{@endtarget}
|
||||
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts):
|
||||
`@Component({...})
|
||||
class MyComponent() {}`|`@Component({...})`
|
||||
syntax(js):
|
||||
`var MyComponent = ng.core.Component({...}).Class({...})`|`ng.core.Component({...})`
|
||||
syntax(dart):
|
||||
`@Component(...)
|
||||
class MyComponent() {}`|`@Component(...)`
|
||||
description:
|
||||
Declares that a class is a component and provides metadata about the component.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts):
|
||||
`@Pipe({...})
|
||||
class MyPipe() {}`|`@Pipe({...})`
|
||||
syntax(js):
|
||||
`var MyPipe = ng.core.Pipe({...}).Class({...})`|`ng.core.Pipe({...})`
|
||||
syntax(dart):
|
||||
`@Pipe(...)
|
||||
class MyPipe() {}`|`@Pipe(...)`
|
||||
description:
|
||||
Declares that a class is a pipe and provides metadata about the pipe.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts):
|
||||
`@Injectable()
|
||||
class MyService() {}`|`@Injectable()`
|
||||
Declares that a class has dependencies that should be injected into the constructor when the dependency
|
||||
injector is creating an instance of this class.
|
||||
syntax(js):
|
||||
`var OtherService = ng.core.Class({constructor: function() { }});
|
||||
var MyService = ng.core.Class({constructor: [OtherService, function(otherService) { }]});`|`var MyService = ng.core.Class({constructor: [OtherService, function(otherService) { }]});`
|
||||
syntax(dart):
|
||||
`@Injectable()
|
||||
class MyService() {}`|`@Injectable()`
|
||||
description:
|
||||
{@target ts dart}Declares that a class has dependencies that should be injected into the constructor when the dependency injector is creating an instance of this class.
|
||||
{@endtarget}
|
||||
{@target js}
|
||||
Declares a service to inject into a class by providing an array with the services with the final item being the function which will receive the injected services.
|
||||
{@endtarget}
|
||||
|
@ -2,31 +2,45 @@
|
||||
Component configuration
|
||||
@cheatsheetIndex 6
|
||||
@description
|
||||
`@Component` extends `@Directive`,
|
||||
so the `@Directive` configuration applies to components as well
|
||||
{@target js}`ng.core.Component` extends `ng.core.Directive`,
|
||||
so the `ng.core.Directive` configuration applies to components as well{@endtarget}
|
||||
{@target ts dart}`@Component` extends `@Directive`,
|
||||
so the `@Directive` configuration applies to components as well{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`viewProviders: [MyService, provide(...)]`|`viewProviders:`
|
||||
syntax(js):
|
||||
`viewProviders: [MyService, ng.core.provide(...)]`|`viewProviders:`
|
||||
description:
|
||||
Array of dependency injection providers scoped to this component's view.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`template: 'Hello {{name}}'
|
||||
templateUrl: 'my-component.html'`|`template:`|`templateUrl:`
|
||||
Inline template / external template url of the component's view.
|
||||
description:
|
||||
Inline template / external template URL of the component's view.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`styles: ['.primary {color: red}']
|
||||
styleUrls: ['my-component.css']`|`styles:`|`styleUrls:`
|
||||
List of inline css styles / external stylesheet urls for styling component’s view.
|
||||
description:
|
||||
List of inline CSS styles / external stylesheet URLs for styling component’s view.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`directives: [MyDirective, MyComponent]`|`directives:`
|
||||
description:
|
||||
List of directives used in the the component’s template.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`pipes: [MyPipe, OtherPipe]`|`pipes:`
|
||||
List of pipes used in the component's template.
|
||||
description:
|
||||
List of pipes used in the component's template.
|
||||
|
@ -2,19 +2,32 @@
|
||||
Dependency injection configuration
|
||||
@cheatsheetIndex 9
|
||||
@description
|
||||
`import {provide} from 'angular2/angular2';`
|
||||
{@target ts}`import {provide} from 'angular2/core';`{@endtarget}
|
||||
{@target js}Available from the `ng.core` namespace{@endtarget}
|
||||
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
`provide(MyService, {useClass: MyMockService})``provide`|`useClass`
|
||||
syntax(ts dart):
|
||||
`provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
|
||||
syntax(js):
|
||||
`ng.core.provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
|
||||
description:
|
||||
Sets or overrides the provider for MyService to the MyMockService class.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
`provide(MyService, {useFactory: myFactory})``provide`|`useFactory`
|
||||
syntax(ts dart):
|
||||
`provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
|
||||
syntax(js):
|
||||
`ng.core.provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
|
||||
description:
|
||||
Sets or overrides the provider for MyService to the myFactory factory function.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
`provide(MyValue, {useValue: 41})``provide`|`useValue`
|
||||
syntax(ts dart):
|
||||
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
|
||||
syntax(js):
|
||||
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
|
||||
description:
|
||||
Sets or overrides the provider for MyValue to the value 41.
|
||||
|
||||
|
@ -2,45 +2,79 @@
|
||||
Class field decorators for directives and components
|
||||
@cheatsheetIndex 7
|
||||
@description
|
||||
`import {Input, ...} from 'angular2/angular2';`
|
||||
{@target ts}`import {Input, ...} from 'angular2/core';`{@endtarget}
|
||||
{@target js}Available from the `ng.core` namespace{@endtarget}
|
||||
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@Input() myProperty;`|`@Input()`
|
||||
Declares an input property that we can update via property binding, e.g.
|
||||
`<my-cmp [my-property]="someExpression">`
|
||||
syntax(js):
|
||||
`ng.core.Input(myProperty, myComponent);`|`ng.core.Input(`|`);`
|
||||
description:
|
||||
Declares an input property that we can update via property binding (e.g.
|
||||
`<my-cmp [my-property]="someExpression">`).
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@Output() myEvent = new EventEmitter();`|`@Output()`
|
||||
Declares an output property that fires events to which we can subscribe with an event binding, e.g. `<my-cmp (my-event)="doSomething()">`
|
||||
syntax(js):
|
||||
`myEvent = new ng.core.EventEmitter(); ng.core.Output(myEvent, myComponent);`|`ng.core.Output(`|`);`
|
||||
description:
|
||||
Declares an output property that fires events to which we can subscribe with an event binding (e.g. `<my-cmp (my-event)="doSomething()">`).
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@HostBinding('[class.valid]') isValid;`|`@HostBinding('[class.valid]')`
|
||||
Binds a host element property (e.g. css class valid) to directive/component property (e.g. isValid)
|
||||
syntax(js):
|
||||
`ng.core.HostBinding('[class.valid]', 'isValid', myComponent);`|`ng.core.HostBinding('[class.valid]', 'isValid'`|`);`
|
||||
description:
|
||||
Binds a host element property (e.g. CSS class valid) to directive/component property (e.g. isValid).
|
||||
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@HostListener('click', ['$event']) onClick(e) {...}`|`@HostListener('click', ['$event'])`
|
||||
Subscribes to a host element event (e.g. click) with a directive/component method (e.g., onClick), optionally passing an argument ($event)
|
||||
syntax(js):
|
||||
`ng.core.HostListener('click', ['$event'], onClick(e) {...}, myComponent);`|`ng.core.HostListener('click', ['$event'], onClick(e)`|`);`
|
||||
description:
|
||||
Subscribes to a host element event (e.g. click) with a directive/component method (e.g. onClick), optionally passing an argument ($event).
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@ContentChild(myPredicate) myChildComponent;`|`@ContentChild(myPredicate)`
|
||||
syntax(js):
|
||||
`ng.core.ContentChild(myPredicate, 'myChildComponent', myComponent);`|`ng.core.ContentChild(myPredicate,`|`);`
|
||||
description:
|
||||
Binds the first result of the component content query (myPredicate) to the myChildComponent property of the class.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@ContentChildren(myPredicate) myChildComponents;`|`@ContentChildren(myPredicate)`
|
||||
syntax(js):
|
||||
`ng.core.ContentChildren(myPredicate, 'myChildComponents', myComponent);`|`ng.core.ContentChildren(myPredicate,`|`);`
|
||||
description:
|
||||
Binds the results of the component content query (myPredicate) to the myChildComponents property of the class.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@ViewChild(myPredicate) myChildComponent;`|`@ViewChild(myPredicate)`
|
||||
syntax(js):
|
||||
`ng.core.ViewChild(myPredicate, 'myChildComponent', myComponent);`|`ng.core.ViewChild(myPredicate,`|`);`
|
||||
description:
|
||||
Binds the first result of the component view query (myPredicate) to the myChildComponent property of the class. Not available for directives.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`@ViewChildren(myPredicate) myChildComponents;`|`@ViewChildren(myPredicate)`
|
||||
Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives.
|
||||
syntax(js):
|
||||
`ng.core.ViewChildren(myPredicate, 'myChildComponents', myComponent);`|`ng.core.ViewChildren(myPredicate,`|`);`
|
||||
description:
|
||||
Binds the results of the component view query (myPredicate) to the myChildComponents property of the class. Not available for directives.
|
||||
|
@ -2,15 +2,23 @@
|
||||
Directive configuration
|
||||
@cheatsheetIndex 5
|
||||
@description
|
||||
`@Directive({ property1: value1, ... }) )`
|
||||
{@target ts}`@Directive({ property1: value1, ... })`{@endtarget}
|
||||
{@target js}`ng.core.Directive({ property1: value1, ... }).Class({...})`{@endtarget}
|
||||
{@target dart}`@Directive(property1: value1, ...)`{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`selector: '.cool-button:not(a)'`|`selector:`
|
||||
Specifies a css selector that identifies this directive within a template. Supported selectors include: `element`,
|
||||
description:
|
||||
Specifies a CSS selector that identifies this directive within a template. Supported selectors include `element`,
|
||||
`[attribute]`, `.class`, and `:not()`.
|
||||
|
||||
Does not support parent-child relationship selectors.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`providers: [MyService, provide(...)]`|`providers:`
|
||||
Array of dependency injection providers for this directive and its children.
|
||||
syntax(js):
|
||||
`providers: [MyService, ng.core.provide(...)]`|`providers:`
|
||||
description:
|
||||
Array of dependency injection providers for this directive and its children.
|
||||
|
@ -2,8 +2,12 @@
|
||||
Forms
|
||||
@cheatsheetIndex 3
|
||||
@description
|
||||
`import {FORM_DIRECTIVES} from 'angular2/angular2';`
|
||||
{@target ts}`import {FORM_DIRECTIVES} from 'angular2/common';`{@endtarget}
|
||||
{@target js}Available from `ng.common.FORM_DIRECTIVES`{@endtarget}
|
||||
{@target dart}Available using `platform_directives` in pubspec{@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
`<input [(ng-model)]="userName">`|`[(ng-model)]`
|
||||
Provides two-way data-binding, parsing and validation for form controls.
|
||||
syntax:
|
||||
`<input [(ngModel)]="userName">`|`[(ngModel)]`
|
||||
description:
|
||||
Provides two-way data-binding, parsing and validation for form controls.
|
||||
|
@ -2,48 +2,87 @@
|
||||
Directive and component change detection and lifecycle hooks
|
||||
@cheatsheetIndex 8
|
||||
@description
|
||||
(implemented as class methods)
|
||||
{@target ts dart}(implemented as class methods){@endtarget}
|
||||
{@target js}(implemented as component properties){@endtarget}
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts):
|
||||
`constructor(myService: MyService, ...) { ... }`|`constructor(myService: MyService, ...)`
|
||||
syntax(js):
|
||||
`constructor: function(MyService, ...) { ... }`|`constructor: function(MyService, ...)`
|
||||
syntax(dart):
|
||||
`MyAppComponent(MyService myService, ...) { ... }`|`MyAppComponent(MyService myService, ...)`
|
||||
description:
|
||||
The class constructor is called before any other lifecycle hook. Use it to inject dependencies, but avoid any serious work here.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngOnChanges(changeRecord) { ... }`|`ngOnChanges(changeRecord)`
|
||||
syntax(js):
|
||||
`ngOnChanges: function(changeRecord) { ... }`|`ngOnChanges: function(changeRecord)`
|
||||
description:
|
||||
Called after every change to input properties and before processing content or child views.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngOnInit() { ... }`|`ngOnInit()`
|
||||
syntax(js):
|
||||
`ngOnInit: function() { ... }`|`ngOnInit: function()`
|
||||
description:
|
||||
Called after the constructor, initializing input properties, and the first call to ngOnChanges.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngDoCheck() { ... }`|`ngDoCheck()`
|
||||
syntax(js):
|
||||
`ngDoCheck: function() { ... }`|`ngDoCheck: function()`
|
||||
description:
|
||||
Called every time that the input properties of a component or a directive are checked. Use it to extend change detection by performing a custom check.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngAfterContentInit() { ... }`|`ngAfterContentInit()`
|
||||
syntax(js):
|
||||
`ngAfterContentInit: function() { ... }`|`ngAfterContentInit: function()`
|
||||
description:
|
||||
Called after ngOnInit when the component's or directive's content has been initialized.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngAfterContentChecked() { ... }`|`ngAfterContentChecked()`
|
||||
syntax(js):
|
||||
`ngAfterContentChecked: function() { ... }`|`ngAfterContentChecked: function()`
|
||||
description:
|
||||
Called after every check of the component's or directive's content.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngAfterViewInit() { ... }`|`ngAfterViewInit()`
|
||||
syntax(js):
|
||||
`ngAfterViewInit: function() { ... }`|`ngAfterViewInit: function()`
|
||||
description:
|
||||
Called after ngAfterContentInit when the component's view has been initialized. Applies to components only.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngAfterViewChecked() { ... }`|`ngAfterViewChecked()`
|
||||
syntax(js):
|
||||
`ngAfterViewChecked: function() { ... }`|`ngAfterViewChecked: function()`
|
||||
description:
|
||||
Called after every check of the component's view. Applies to components only.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`ngOnDestroy() { ... }`|`ngOnDestroy()`
|
||||
Called once, before the instance is destroyed.
|
||||
syntax(js):
|
||||
`ngOnDestroy: function() { ... }`|`ngOnDestroy: function()`
|
||||
description:
|
||||
Called once, before the instance is destroyed.
|
||||
|
@ -2,54 +2,100 @@
|
||||
Routing and navigation
|
||||
@cheatsheetIndex 10
|
||||
@description
|
||||
`import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, ...} from 'angular2/router';`
|
||||
{@target ts}`import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, ...} from 'angular2/router';`{@endtarget}
|
||||
{@target js}Available from the `ng.router` namespace{@endtarget}
|
||||
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts):
|
||||
`@RouteConfig([
|
||||
{ path: '/:myParam', component: MyComponent, as: 'MyCmp' },
|
||||
{ path: '/staticPath', component: ..., as: ...},
|
||||
{ path: '/*wildCardParam', component: ..., as: ...}
|
||||
{ path: '/:myParam', component: MyComponent, name: 'MyCmp' },
|
||||
{ path: '/staticPath', component: ..., name: ...},
|
||||
{ path: '/*wildCardParam', component: ..., name: ...}
|
||||
])
|
||||
class MyComponent() {}`|`@RouteConfig`
|
||||
Configures routes for the decorated component. Supports static, parameterized and wildcard routes.
|
||||
syntax(js):
|
||||
`var MyComponent = ng.router.RouteConfig([
|
||||
{ path: '/:myParam', component: MyComponent, name: 'MyCmp' },
|
||||
{ path: '/staticPath', component: ..., name: ...},
|
||||
{ path: '/*wildCardParam', component: ..., name: ...}
|
||||
]).Class({
|
||||
constructor: function() {}
|
||||
});`|`ng.router.RouteConfig`
|
||||
syntax(dart):
|
||||
`@RouteConfig(const [
|
||||
const Route(path: '/:myParam', component: MyComponent, name: 'MyCmp' ),
|
||||
])`|`@RouteConfig`
|
||||
description:
|
||||
Configures routes for the decorated component. Supports static, parameterized, and wildcard routes.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<router-outlet></router-outlet>`|`router-outlet`
|
||||
description:
|
||||
Marks the location to load the component of the active route.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
`<a [router-link]="[ '/MyCmp', {myParam: 'value' } ]">`|`[router-link]`
|
||||
syntax:
|
||||
`<a [routerLink]="[ '/MyCmp', {myParam: 'value' } ]">`|`[routerLink]`
|
||||
description:
|
||||
Creates a link to a different view based on a route instruction consisting of a route name and optional parameters. The route name matches the as property of a configured route. Add the '/' prefix to navigate to a root route; add the './' prefix for a child route.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts):
|
||||
`@CanActivate(() => { ... })class MyComponent() {}`|`@CanActivate`
|
||||
A component decorator defining a function that the router should call first to determine if it should activate this component. Should return a boolean or a promise.
|
||||
syntax(js):
|
||||
`var MyComponent = ng.router.CanActivate(function() { ... }).Component({...}).Class({constructor: ...});`|`ng.router.CanActivate(function() { ... })`
|
||||
syntax(dart):
|
||||
`@CanActivate(() => ...)class MyComponent() {}`|`@CanActivate`
|
||||
description:
|
||||
A component decorator defining a function that the router should call first to determine if it should activate this component. Should return a boolean or a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget}.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`routerOnActivate(nextInstruction, prevInstruction) { ... }`|`routerOnActivate`
|
||||
After navigating to a component, the router calls component's routerOnActivate method (if defined).
|
||||
syntax(js):
|
||||
`routerOnActivate: function(nextInstruction, prevInstruction) { ... }`|`routerOnActivate`
|
||||
description:
|
||||
After navigating to a component, the router calls the component's routerOnActivate method (if defined).
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`routerCanReuse(nextInstruction, prevInstruction) { ... }`|`routerCanReuse`
|
||||
The router calls a component's routerCanReuse method (if defined) to determine whether to reuse the instance or destroy it and create a new instance. Should return a boolean or a promise.
|
||||
syntax(js):
|
||||
`routerCanReuse: function(nextInstruction, prevInstruction) { ... }`|`routerCanReuse`
|
||||
description:
|
||||
The router calls a component's routerCanReuse method (if defined) to determine whether to reuse the instance or destroy it and create a new instance. Should return a boolean or a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget}.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`routerOnReuse(nextInstruction, prevInstruction) { ... }`|`routerOnReuse`
|
||||
syntax(js):
|
||||
`routerOnReuse: function(nextInstruction, prevInstruction) { ... }`|`routerOnReuse`
|
||||
description:
|
||||
The router calls the component's routerOnReuse method (if defined) when it re-uses a component instance.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`routerCanDeactivate(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate`
|
||||
The router calls the routerCanDeactivate methods (if defined) of every component that would be removed after a navigation. The navigation proceeds if and only if all such methods return true or a promise that is resolved.
|
||||
syntax(js):
|
||||
`routerCanDeactivate: function(nextInstruction, prevInstruction) { ... }`|`routerCanDeactivate`
|
||||
description:
|
||||
The router calls the routerCanDeactivate methods (if defined) of every component that would be removed after a navigation. The navigation proceeds if and only if all such methods return true or a {@target js ts}promise that is resolved{@endtarget}{@target dart}future that completes successfully{@endtarget}.
|
||||
|
||||
|
||||
@cheatsheetItem
|
||||
syntax(ts dart):
|
||||
`routerOnDeactivate(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
|
||||
Called before the directive is removed as the result of a route change. May return a promise that pauses removing the directive until the promise resolves.
|
||||
syntax(js):
|
||||
`routerOnDeactivate: function(nextInstruction, prevInstruction) { ... }`|`routerOnDeactivate`
|
||||
description:
|
||||
Called before the directive is removed as the result of a route change. May return a {@target js ts}promise{@endtarget}{@target dart}future{@endtarget} that pauses removing the directive until the {@target js ts}promise resolves{@endtarget}{@target dart}future completes{@endtarget}.
|
||||
|
@ -4,53 +4,77 @@ Template syntax
|
||||
@description
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<input [value]="firstName">`|`[value]`
|
||||
description:
|
||||
Binds property `value` to the result of expression `firstName`.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<div [attr.role]="myAriaRole">`|`[attr.role]`
|
||||
description:
|
||||
Binds attribute `role` to the result of expression `myAriaRole`.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<div [class.extra-sparkle]="isDelightful">`|`[class.extra-sparkle]`
|
||||
Binds the presence of the css class `extra-sparkle` on the element to the truthiness of the expression `isDelightful`.
|
||||
description:
|
||||
Binds the presence of the CSS class `extra-sparkle` on the element to the truthiness of the expression `isDelightful`.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<div [style.width.px]="mySize">`|`[style.width.px]`
|
||||
description:
|
||||
Binds style property `width` to the result of expression `mySize` in pixels. Units are optional.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<button (click)="readRainbow($event)">`|`(click)`
|
||||
description:
|
||||
Calls method `readRainbow` when a click event is triggered on this button element (or its children) and passes in the event object.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<div title="Hello {{ponyName}}">`|`{{ponyName}}`
|
||||
description:
|
||||
Binds a property to an interpolated string, e.g. "Hello Seabiscuit". Equivalent to:
|
||||
`<div [title]="'Hello' + ponyName">`
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<p>Hello {{ponyName}}</p>`|`{{ponyName}}`
|
||||
description:
|
||||
Binds text content to an interpolated string, e.g. "Hello Seabiscuit".
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<my-cmp [(title)]="name">`|`[(title)]`
|
||||
Sets up two-way data binding. Equivalent to: `<my-cmp [title]="name" (title-change)="name=$event">`
|
||||
description:
|
||||
Sets up two-way data binding. Equivalent to: `<my-cmp [title]="name" (titleChange)="name=$event">`
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<video #movieplayer ...>
|
||||
<button (click)="movieplayer.play()">
|
||||
</video>`|`#movieplayer`|`(click)`
|
||||
description:
|
||||
Creates a local variable `movieplayer` that provides access to the `video` element instance in data-binding and event-binding expressions in the current template.
|
||||
|
||||
@cheatsheetItem
|
||||
`<p *my-unless="myExpression">...</p>`|`*my-unless`
|
||||
syntax:
|
||||
`<p *myUnless="myExpression">...</p>`|`*myUnless`
|
||||
description:
|
||||
The `*` symbol means that the current element will be turned into an embedded template. Equivalent to:
|
||||
`<template [myless]="myExpression"><p>...</p></template>`
|
||||
`<template [myUnless]="myExpression"><p>...</p></template>`
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<p>Card No.: {{cardNumber | myCreditCardNumberFormatter}}</p>`|`{{cardNumber | myCreditCardNumberFormatter}}`
|
||||
Transforms the current value of expression `cardNumber` via the pipe called `creditCardNumberFormatter`.
|
||||
description:
|
||||
Transforms the current value of expression `cardNumber` via the pipe called `myCreditCardNumberFormatter`.
|
||||
|
||||
@cheatsheetItem
|
||||
syntax:
|
||||
`<p>Employer: {{employer?.companyName}}</p>`|`{{employer?.companyName}}`
|
||||
description:
|
||||
The Elvis operator (`?`) means that the `employer` field is optional and if `undefined`, the rest of the expression should be ignored.
|
||||
|
@ -359,20 +359,20 @@ Example of conditionally included template:
|
||||
|
||||
```
|
||||
Hello {{user}}!
|
||||
<div template="ng-if: isAdministrator">
|
||||
<div template="ngIf: isAdministrator">
|
||||
...administrator menu here...
|
||||
</div>
|
||||
```
|
||||
|
||||
In the above example the `ng-if` directive determines whether the child view (an instance of the child template) should be
|
||||
inserted into the root view. The `ng-if` makes this decision based on if the `isAdministrator` binding is true.
|
||||
In the above example the `ngIf` directive determines whether the child view (an instance of the child template) should be
|
||||
inserted into the root view. The `ngIf` makes this decision based on if the `isAdministrator` binding is true.
|
||||
|
||||
The above example is in the short form, for better clarity let's rewrite it in the canonical form, which is functionally
|
||||
identical.
|
||||
|
||||
```
|
||||
Hello {{user}}!
|
||||
<template [ng-if]="isAdministrator">
|
||||
<template [ngIf]="isAdministrator">
|
||||
<div>
|
||||
...administrator menu here...
|
||||
</div>
|
||||
@ -383,22 +383,22 @@ Hello {{user}}!
|
||||
### Template Microsyntax
|
||||
|
||||
Often times it is necessary to encode a lot of different bindings into a template to control how the instantiation
|
||||
of the templates occurs. One such example is `ng-for`.
|
||||
of the templates occurs. One such example is `ngFor`.
|
||||
|
||||
```
|
||||
<form #foo=form>
|
||||
</form>
|
||||
<ul>
|
||||
<template [ng-for] #person [ng-for-of]="people" #i="index">
|
||||
<template [ngFor] #person [ngForOf]="people" #i="index">
|
||||
<li>{{i}}. {{person}}<li>
|
||||
</template>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Where:
|
||||
* `[ng-for]` triggers the for directive.
|
||||
* `#person` exports the implicit `ng-for` item.
|
||||
* `[ng-for-of]="people"` binds an iterable object to the `ng-for` controller.
|
||||
* `[ngFor]` triggers the for directive.
|
||||
* `#person` exports the implicit `ngFor` item.
|
||||
* `[ngForOf]="people"` binds an iterable object to the `ngFor` controller.
|
||||
* `#i=index` exports item index as `i`.
|
||||
|
||||
The above example is explicit but quite wordy. For this reason in most situations a short hand version of the
|
||||
@ -406,7 +406,7 @@ syntax is preferable.
|
||||
|
||||
```
|
||||
<ul>
|
||||
<li template="ng-for; #person; of=people; #i=index;">{{i}}. {{person}}<li>
|
||||
<li template="ngFor; #person; of=people; #i=index;">{{i}}. {{person}}<li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
@ -416,24 +416,24 @@ which allows us to further shorten the text.
|
||||
|
||||
```
|
||||
<ul>
|
||||
<li template="ng-for #person of people #i=index">{{i}}. {{person}}<li>
|
||||
<li template="ngFor #person of people #i=index">{{i}}. {{person}}<li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
We can also optionally use `var` instead of `#` and add `:` to `for` which creates the following recommended
|
||||
microsyntax for `ng-for`.
|
||||
microsyntax for `ngFor`.
|
||||
|
||||
```
|
||||
<ul>
|
||||
<li template="ng-for: var person of people; var i=index">{{i}}. {{person}}<li>
|
||||
<li template="ngFor: var person of people; var i=index">{{i}}. {{person}}<li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
Finally, we can move the `ng-for` keyword to the left hand side and prefix it with `*` as so:
|
||||
Finally, we can move the `ngFor` keyword to the left hand side and prefix it with `*` as so:
|
||||
|
||||
```
|
||||
<ul>
|
||||
<li *ng-for="var person of people; var i=index">{{i}}. {{person}}<li>
|
||||
<li *ngFor="var person of people; var i=index">{{i}}. {{person}}<li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
@ -456,7 +456,7 @@ Where
|
||||
* `local` is a local identifier for local variables.
|
||||
* `internal` is an internal variable which the directive exports for binding.
|
||||
* `key` is an attribute name usually only used to trigger a specific directive.
|
||||
* `keyExpression` is an property name to which the expression will be bound to.
|
||||
* `keyExpression` is a property name to which the expression will be bound to.
|
||||
* `varExport` allows exporting of directive internal state as variables for further binding. If no `internal` name
|
||||
is specified, the exporting is to an implicit variable.
|
||||
* `microsyntax` allows you to build a simple microsyntax which can still clearly identify which expressions bind to
|
||||
@ -544,7 +544,7 @@ Angular are:
|
||||
<div title="{{expression}}">{{expression}}</div>
|
||||
<div [title]="expression">...</div>
|
||||
<div bind-title="expression">...</div>
|
||||
<div template="ng-if: expression">...</div>
|
||||
<div template="ngIf: expression">...</div>
|
||||
```
|
||||
|
||||
Expressions are simplified version of expression in the language in which you are writing your application. (i.e.
|
||||
|
@ -161,7 +161,7 @@ Example of usage:
|
||||
|
||||
## Directives that use a ViewContainer
|
||||
|
||||
Directives that use a ViewContainer can control instantiation of child views which are then inserted into the DOM. (Examples are `ng-if` and `ng-for`.)
|
||||
Directives that use a ViewContainer can control instantiation of child views which are then inserted into the DOM. (Examples are `ngIf` and `ngFor`.)
|
||||
|
||||
* Every `template` element creates a `ProtoView` which can be used to create Views via the ViewContainer.
|
||||
* The child views show up as siblings of the directive in the DOM.
|
||||
|
@ -94,7 +94,7 @@ Let's start with a View such as:
|
||||
|
||||
```
|
||||
<ul>
|
||||
<li template="ng-for: #person of people">{{person}}</li>
|
||||
<li template="ngFor: #person of people">{{person}}</li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
239
modules/angular2/docs/migration/kebab-case.md
Normal file
239
modules/angular2/docs/migration/kebab-case.md
Normal file
@ -0,0 +1,239 @@
|
||||
Angular2 templates are now case-sensitive and use camelCase in many places where dash-case was previously used ([design doc] (https://docs.google.com/document/d/1UMxTIUBTIUZNfOqwMhkLg0ANFSBtLIK9JsIu77EZaBA/edit?ts=564f7dd4)).
|
||||
|
||||
## Overview
|
||||
|
||||
Where you used to write:
|
||||
|
||||
```
|
||||
<my-cmp (some-event)="someAction()" [some-property]="expression" #some-var>
|
||||
```
|
||||
|
||||
in order to:
|
||||
- bind to the `someEvent` event,
|
||||
- bind to the `someProperty` property,
|
||||
- create a `someVar` local variable
|
||||
|
||||
You should now write:
|
||||
|
||||
```
|
||||
<my-cmp (someEvent)="someAction()" [someProperty]="expression" #someVar>
|
||||
```
|
||||
|
||||
Notes:
|
||||
- while tag name are case sensitive, the best practice is to use dash case for component elements so that the browser
|
||||
interpret them as custom elements,
|
||||
- `(some-event)` would now bind to the `some-event` event (i.e. there is no implicit dash to camel case conversion),
|
||||
- `[some-property]` would now bind to the `some-property` property (i.e. there is no implicit dash to camel case conversion),
|
||||
- `#some-var` is not allowed any more ("-" can not be used in variable names).
|
||||
|
||||
## Migration
|
||||
|
||||
#### Templates
|
||||
|
||||
1. Directives selectors, property bindings, event bindings, template variables and template element attributes should be changed to camel case:
|
||||
|
||||
Examples:
|
||||
- `<p *ng-if="cond">` should be changed to `<p *ngIf="cond">`,
|
||||
- `<my-cmp [my-prop]="exp">` should be changed to `<my-cmp [myProp]="exp">`,
|
||||
- `<my-cmp (my-event)="action()">` should be changed to `<my-cmp (myEvent)="action()">`,
|
||||
- `<my-cmp [(my-prop)]="prop">` should be changed to `<my-cmp [(myProp)]="prop">`,
|
||||
- `<input #my-input>` should be changed to `<input #myInput>`,
|
||||
- `<template ng-for #my-item [ng-for-of]=items #my-index="index">` should be changed to `<template ngFor #myItem [ngForOf]=items #myIndex="index">`,
|
||||
|
||||
Note: while the tag names are now case-sensitive the best practice is to keep them lower-dash-cased so that the browser
|
||||
treat them as custom elements. Using dashes in custom element names is required by the [Custom Element HTML Spec](http://www.w3.org/TR/custom-elements/#concepts).
|
||||
This explains why the `<router-outlet>` component is left unchanged.
|
||||
|
||||
`on-`, `bindon-`, `bind-` and `var-` prefixes are still part of the canonical syntax and should remain unchanged (lower cased):
|
||||
- `on-some-event` should be changed to `on-someEvent`,
|
||||
- `bind-my-prop` should be changed to `bind-myProp`,
|
||||
- `bindon-my-prop` should be changed to `bindon-myProp`,
|
||||
- `var-my-var` should be changed to `var-myVar`.
|
||||
|
||||
2. Update variable binding
|
||||
|
||||
- `<p #var1="a-b" var-var2="c-d">` should be changed to `<p #var1="aB" var-var2="cD">`
|
||||
|
||||
3. The `template` attribute values should also be updated in the same way
|
||||
|
||||
`<p template="ng-for #my-item of items #my-index = index">` should be changed to `<p template="ngFor #myItem of items #myIndex = index">`.
|
||||
|
||||
Note that both angular directives and your own directives must be updated in the same way.
|
||||
|
||||
#### Directives and Components
|
||||
|
||||
Take the following steps to upgrade your directives and components:
|
||||
|
||||
1. Update the selector:
|
||||
```
|
||||
@Directive({selector: 'tag[attr][name=value]'})
|
||||
@Component({selector: 'tag[attr][name=value]'})
|
||||
```
|
||||
|
||||
Tag and attributes names are case sensitive:
|
||||
- For tag names, the best practice is to keep them lower dash cased, do not update them,
|
||||
- For attribute names, the best practice is to convert them from lower dash case to camel case.
|
||||
|
||||
Examples:
|
||||
- `custom-tag` should stay `custom-tag` (do not update tag names),
|
||||
- `[attr-name]` should be updated to `[attrName]`,
|
||||
- `[attr-name=someValue]` should be updated to `[attrName=someValue]`,
|
||||
- `custom-tag[attr-name=someValue]` should be updated to `custom-tag[attrName=someValue]`
|
||||
|
||||
Note: attribute values and classes are still matched case insensitive.
|
||||
|
||||
2. Update the inputs
|
||||
```
|
||||
@Directive({inputs: ['myProp', 'myOtherProp: my-attr-name']})
|
||||
```
|
||||
|
||||
As attribute names are now case sensitive, they should be converted from dash to camel case where they are specified.
|
||||
The previous decorator becomes:
|
||||
|
||||
```
|
||||
@Directive({inputs: ['myProp', 'myOtherProp: myAttrName']})
|
||||
```
|
||||
|
||||
Notes:
|
||||
- only the long syntax (with ":") needs to be updated,
|
||||
- `properties` is the legacy name for `inputs` and should be updated in the same way - it is a good idea to replace
|
||||
`properties` with `inputs` at the same time as support for the former will be removed soon.
|
||||
|
||||
The same applies for the `@Input` decorator:
|
||||
|
||||
```
|
||||
@Input() myProp;
|
||||
@Input('my-attr-name') myProp;
|
||||
```
|
||||
|
||||
That is they only need to be updated when the attribute name is specified:
|
||||
|
||||
```
|
||||
@Input() myProp; // Nothing to update
|
||||
@Input('myAttrName') myProp; // Convert the attribute name to camel case
|
||||
```
|
||||
|
||||
3. Update the outputs
|
||||
|
||||
Update the outputs in the same way the inputs are updated:
|
||||
|
||||
```
|
||||
@Directive({outputs: ['myEvent', 'myOtherEvent: my-event-name']})
|
||||
```
|
||||
|
||||
should be updated to:
|
||||
|
||||
```
|
||||
@Directive({outputs: ['myEvent', 'myOtherEvent: myEventName']})
|
||||
```
|
||||
|
||||
If you use `events` instead of `outputs` you should update in the same way and switch to `outputs` as `events` is deprecated.
|
||||
|
||||
```
|
||||
@Output() myEvent;
|
||||
@Output('my-event-name') myEvent;
|
||||
```
|
||||
|
||||
should be changed to:
|
||||
|
||||
```
|
||||
@Output() myEvent;
|
||||
@Output('myEventName') myEvent;
|
||||
```
|
||||
|
||||
4. Update the host bindings
|
||||
|
||||
```
|
||||
@Directive({
|
||||
host: {
|
||||
'[some-prop]': 'exp',
|
||||
'[style.background-color]': 'exp',
|
||||
'[class.some-class]': 'exp',
|
||||
'[attr.some-attr]': 'exp',
|
||||
'(some-event)': 'action()',
|
||||
'some-attr': 'value'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
should be changed to:
|
||||
|
||||
```
|
||||
@Directive({
|
||||
host: {
|
||||
'[someProp]': 'exp',
|
||||
'[style.background-color]': 'exp',
|
||||
'[class.some-class]': 'exp',
|
||||
'[attr.some-attr]': 'exp',
|
||||
'(someEvent)': 'action()',
|
||||
'some-attr': 'value'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
The property bindings (`[...]`) and event bindings (`(...)`) must be updated in the same way as they are updated in a
|
||||
template - ie converted to camel case (reminder: `[attr.]`, `[class.]` and `[style.]` should not be converted to camel case).
|
||||
|
||||
5. Update export name
|
||||
|
||||
```
|
||||
@Directive({
|
||||
exportAs: 'some-name'
|
||||
})
|
||||
```
|
||||
|
||||
should be changed to:
|
||||
|
||||
```
|
||||
@Directive({
|
||||
exportAs: 'someName'
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
# CSS
|
||||
|
||||
As the attribute names from your templates have been updated from dash to camel case, you should also reflect the changes
|
||||
in your stylesheets.
|
||||
|
||||
The attributes that need to be updated are the ones used in the selector and the inputs of your directives.
|
||||
|
||||
Before:
|
||||
|
||||
```
|
||||
// Directive
|
||||
@Directive({
|
||||
selector: '[my-dir]',
|
||||
inputs: ['someProp: some-input'],
|
||||
})
|
||||
|
||||
<!-- template -->
|
||||
<div my-dir some-input="some value" not-an-input></div>
|
||||
|
||||
/* css */
|
||||
[my-dir] { ... }
|
||||
[some-input] { ... }
|
||||
[not-an-input] { ... }
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```
|
||||
// Directive
|
||||
@Directive({
|
||||
selector: '[myDir]',
|
||||
inputs: ['someProp: someInput'],
|
||||
})
|
||||
|
||||
<!-- template -->
|
||||
<div myDir someInput="some value" not-an-input></div>
|
||||
|
||||
/* css */
|
||||
[myDir] { ... }
|
||||
[someInput] { ... }
|
||||
[not-an-input] { ... }
|
||||
```
|
||||
|
||||
Notes:
|
||||
- `not-an-input` is not used in a selector nor it is an input of a directive, it need not be camel cased,
|
||||
- CSS selectors are case insensitive you can use `[myDir]`, `[mydir]` or any other casing.
|
@ -55,7 +55,7 @@ System.import("app");
|
||||
```TypeScript
|
||||
// app.ts
|
||||
import {Component, View, platform} from "angular2/core";
|
||||
import {WORKER_APP_PLATFORM, setupWebWorker} from "angular2/platform/worker_app";
|
||||
import {WORKER_APP_PLATFORM, WORKER_APP_APPLICATION} from "angular2/platform/worker_app";
|
||||
|
||||
@Component({
|
||||
selector: "hello-world"
|
||||
@ -68,7 +68,7 @@ export class HelloWorld {
|
||||
}
|
||||
|
||||
platform([WORKER_APP_PLATFORM])
|
||||
.asyncApplication(setupWebWorker, optionalProviders?)
|
||||
.application([WORKER_APP_APPLICATION])
|
||||
.then((ref) => ref.bootstrap(RootComponent));
|
||||
```
|
||||
There's a few important things to note here:
|
||||
@ -125,26 +125,26 @@ class HelloWorld {
|
||||
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
platform([WORKER_APP_PLATFORM])
|
||||
.asyncApplication(setupIsolate(replyTo))
|
||||
.then((ref) => ref.bootstrap(RootComponent));
|
||||
platform([WORKER_APP_PLATFORM, new Provider(RENDER_SEND_PORT, useValue: replyTo)])
|
||||
.application([WORKER_APP_APPLICATION])
|
||||
.bootstrap(RootComponent);
|
||||
}
|
||||
|
||||
```
|
||||
This code is nearly the same as the TypeScript version with just a couple key differences:
|
||||
* We don't have a `loader.js` file. Dart applications don't need this file because you don't need a module loader.
|
||||
* We pass a `SendPort` to `bootstrapWebWorker`. Dart applications use the Isolate API, which communicates via
|
||||
* We provide a `SendPort` through DI using the token `RENDER_SEND_PORT`. Dart applications use the Isolate API, which communicates via
|
||||
Dart's Port abstraction. When you call `setupIsolate` from the UI thread, angular starts a new Isolate to run
|
||||
your application logic. When Dart starts a new Isolate it passes a `SendPort` to that Isolate so that it
|
||||
can communicate with the Isolate that spawned it. You need to pass this `SendPort` to `bootstrapWebWorker`
|
||||
can communicate with the Isolate that spawned it. You need to provide this `SendPort` through DI
|
||||
so that Angular can communicate with the UI.
|
||||
* You need to set up `ReflectionCapabilities` on both the UI and Worker. Just like writing non-concurrent
|
||||
Angular2 Dart applications you need to set up the reflector. You should not use Reflection in production,
|
||||
but should use the angular 2 transformer to remove it in your final JS code. Note there's currently a bug
|
||||
with running the transformer on your UI code (#3971). You can (and should) pass the file where you call
|
||||
`bootstrapWebWorker` as an entry point to the transformer, but you should not pass your UI index file
|
||||
`bootstrap` as an entry point to the transformer, but you should not pass your UI index file
|
||||
to the transformer until that bug is fixed.
|
||||
* In dart we call `asyncApplication` instead of `application` because starting an isolate in Dart is asyncronous
|
||||
* In dart we call `asyncApplication` instead of `application` from the render thread because starting an isolate in Dart is asyncronous
|
||||
whereas starting a new WebWorker in JavaScript is a synchronous operation.
|
||||
|
||||
## Writing WebWorker Compatible Components
|
||||
@ -371,14 +371,14 @@ In TypeScript:
|
||||
import {platform, Provider, APP_INITIALIZER, Injector} from 'angular2/core';
|
||||
import {
|
||||
WORKER_RENDER_PLATFORM,
|
||||
WORKER_RENDER_APP_COMMON,
|
||||
WORKER_RENDER_APPLICATION_COMMON,
|
||||
initializeGenericWorkerRenderer,
|
||||
MessageBus
|
||||
} from 'angular2/platform/worker_render';
|
||||
|
||||
var bus = new MyAwesomeMessageBus();
|
||||
platform([WORKER_RENDER_PLATFORM])
|
||||
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, {useValue: bus}),
|
||||
.application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, {useValue: bus}),
|
||||
new Provider(APP_INITIALIZER, {
|
||||
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
|
||||
deps: [Injector],
|
||||
@ -392,18 +392,22 @@ import {WORKER_APP_PLATFORM, genericWorkerAppProviders} from "angular2/platform/
|
||||
import {NgZone, platform, Provider} from "angular/core";
|
||||
import {MyApp} from './app';
|
||||
|
||||
platform([WORKER_APP_PLATFORM_PROVIDERS])
|
||||
.asyncApplication(initAppThread, optionalProviders?)
|
||||
.then((ref) => ref.bootstrap(MyApp));
|
||||
/**
|
||||
* Do initialization work here to set up the app thread and MessageBus;
|
||||
* Once you have a working MessageBus you should bootstrap your app.
|
||||
*/
|
||||
|
||||
function initAppThread(zone: NgZone): Promise<Array<Type | Provider | any[]>> {
|
||||
platform([WORKER_APP_PLATFORM_PROVIDERS])
|
||||
.application([WORKER_APP_APPLICATION_COMMON, new Provider(MessageBus, {useValue: bus}),
|
||||
new Provider(APP_INITIALIZER, {useFactory: (zone, bus) => () => initAppThread(zone, bus), multi: true, deps: [NgZone, MessageBus]})])
|
||||
.bootstrap(MyApp);
|
||||
|
||||
function initAppThread(zone: NgZone, bus: MyAwesomeMessageBus): void{
|
||||
/**
|
||||
* Do initializtion work here to set up the app thread and MessageBus
|
||||
* Once you have a working MessageBus that communicates with the render thread you should call genericWorkerAppProviders
|
||||
* to get a list of Providers.
|
||||
*/
|
||||
var bus = new MyAwesomeMessageBus();
|
||||
return genericWorkerAppProviders(myBus, zone);
|
||||
* Here you can do any initilization work that requires the app providers to be initialized.
|
||||
* At a minimum, you must attach your bus to the zone and setup a DOM adapter.
|
||||
* Depending on your environment you may choose to do more work here.
|
||||
*/
|
||||
}
|
||||
```
|
||||
In Dart:
|
||||
@ -415,7 +419,7 @@ import 'package:angular2/platform/worker_render.dart';
|
||||
main() {
|
||||
var bus = new MyAwesomeMessageBus();
|
||||
platform([WORKER_RENDER_PLATFORM])
|
||||
.application([WORKER_RENDER_APP_COMMON, new Provider(MessageBus, useValue: bus),
|
||||
.application([WORKER_RENDER_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
|
||||
new Provider(APP_INITIALIZER,
|
||||
useFactory: (injector) => () => initializeGenericWorkerRenderer(injector),
|
||||
deps: [Injector],
|
||||
@ -432,27 +436,30 @@ import "package:angular2/core.dart";
|
||||
import "./app.dart" show MyApp;
|
||||
|
||||
main() {
|
||||
/**
|
||||
* Do initialization work here to set up the app thread and MessageBus;
|
||||
* Once you have a working MessageBus you should bootstrap your app.
|
||||
*/
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
platform([WORKER_APP_PLATFORM_PROVIDERS])
|
||||
.asyncApplication(initAppThread, optionalProviders?)
|
||||
.then((ref) => ref.bootstrap(MyApp));
|
||||
.application([WORKER_APP_APPLICATION_COMMON, new Provider(MessageBus, useValue: bus),
|
||||
new Provider(APP_INITIALIZER, useFactory: (zone, bus) => () => initAppThread(zone, bus), multi: true, deps: [NgZone, MessageBus])])
|
||||
.bootstrap(MyApp);
|
||||
}
|
||||
|
||||
|
||||
Future<dynamic> initAppThread(NgZone zone) {
|
||||
var bus = new MyAwesomeMessageBus();
|
||||
return genericWorkerAppProviders(myBus, zone);
|
||||
void initAppThread(NgZone zone) {
|
||||
/**
|
||||
* Here you can do any initilization work that requires the app providers to be initialized.
|
||||
* At a minimum, you must attach your bus to the zone and setup a DOM adapter.
|
||||
* Depending on your environment you may choose to do more work here.
|
||||
*/
|
||||
}
|
||||
```
|
||||
Notice how we use the `WORKER_RENDER_APP_COMMON` providers instead of the `WORKER_RENDER_APP` providers on the render thread.
|
||||
This is because the `WORKER_RENDER_APP` providers include an application initializer that starts a new WebWorker/Isolate.
|
||||
The `WORKER_RENDER_APP_COMMON` providers make no assumption about where your application code lives.
|
||||
Notice how we use the `WORKER_RENDER_APPLICTION_COMMON` providers instead of the `WORKER_RENDER_APPLICATION` providers on the render thread.
|
||||
This is because the `WORKER_RENDER_APPLICATION` providers include an application initializer that starts a new WebWorker/Isolate.
|
||||
The `WORKER_RENDER_APPLICATION_COMMON` providers make no assumption about where your application code lives.
|
||||
However, we now need to provide our own app initializer. At the very least this initializer needs to call `initializeGenericWorkerRenderer`.
|
||||
This function performs necessary setup work to bootstrap the application.
|
||||
|
||||
Similarly we don&t call `setupWebWorker` or `setupIsolate` from the application thread.
|
||||
Instead we have our own initilization method that sets up our MessageBus and calls `genericWorkerAppProviders`
|
||||
to finish setting up the application injector.
|
||||
|
||||
## MessageBroker
|
||||
The MessageBroker is a higher level messaging abstraction that sits on top of the MessageBus. It is used when you
|
||||
|
@ -0,0 +1,30 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {MinLengthValidator, MaxLengthValidator} from 'angular2/common';
|
||||
|
||||
// #docregion min
|
||||
@Component({
|
||||
selector: 'min-cmp',
|
||||
directives: [MinLengthValidator],
|
||||
template: `
|
||||
<form>
|
||||
<p>Year: <input ngControl="year" minlength="2"></p>
|
||||
</form>
|
||||
`
|
||||
})
|
||||
class MinLengthTestComponent {
|
||||
}
|
||||
// #enddocregion
|
||||
|
||||
// #docregion max
|
||||
@Component({
|
||||
selector: 'max-cmp',
|
||||
directives: [MaxLengthValidator],
|
||||
template: `
|
||||
<form>
|
||||
<p>Year: <input ngControl="year" maxlength="4"></p>
|
||||
</form>
|
||||
`
|
||||
})
|
||||
class MaxLengthTestComponent {
|
||||
}
|
||||
// #enddocregion
|
@ -0,0 +1,19 @@
|
||||
import {provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {UrlResolver} from 'angular2/compiler';
|
||||
|
||||
var MyApp;
|
||||
|
||||
// #docregion url_resolver
|
||||
class MyUrlResolver extends UrlResolver {
|
||||
resolve(baseUrl: string, url: string): string {
|
||||
// Serve CSS files from a special CDN.
|
||||
if (url.substr(-4) === '.css') {
|
||||
return super.resolve('http://cdn.myapp.com/css/', url);
|
||||
}
|
||||
return super.resolve(baseUrl, url);
|
||||
}
|
||||
}
|
||||
|
||||
bootstrap(MyApp, [provide(UrlResolver, {useClass: MyUrlResolver})]);
|
||||
// #enddocregion
|
@ -0,0 +1,8 @@
|
||||
import {DebugElement} from 'angular2/core';
|
||||
|
||||
var debugElement: DebugElement;
|
||||
var predicate;
|
||||
|
||||
// #docregion scope_all
|
||||
debugElement.query(predicate);
|
||||
// #enddocregion
|
@ -0,0 +1,26 @@
|
||||
import {Inject, Injector, forwardRef, resolveForwardRef, ForwardRefFn} from 'angular2/core';
|
||||
|
||||
// #docregion forward_ref_fn
|
||||
var ref = forwardRef(() => Lock);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion forward_ref
|
||||
class Door {
|
||||
lock: Lock;
|
||||
constructor(@Inject(forwardRef(() => Lock)) lock: Lock) { this.lock = lock; }
|
||||
}
|
||||
|
||||
// Only at this point Lock is defined.
|
||||
class Lock {}
|
||||
|
||||
var injector = Injector.resolveAndCreate([Door, Lock]);
|
||||
var door = injector.get(Door);
|
||||
expect(door instanceof Door).toBe(true);
|
||||
expect(door.lock instanceof Lock).toBe(true);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion resolve_forward_ref
|
||||
var ref = forwardRef(() => "refValue");
|
||||
expect(resolveForwardRef(ref)).toEqual("refValue");
|
||||
expect(resolveForwardRef("regularValue")).toEqual("regularValue");
|
||||
// #enddocregion
|
@ -0,0 +1,10 @@
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {NG_VALIDATORS} from 'angular2/common';
|
||||
import {Provider} from 'angular2/core';
|
||||
|
||||
let MyApp = null;
|
||||
let myValidator = null;
|
||||
|
||||
// #docregion ng_validators
|
||||
bootstrap(MyApp, [new Provider(NG_VALIDATORS, {useValue: myValidator, multi: true})]);
|
||||
// #enddocregion
|
@ -1,12 +1,13 @@
|
||||
import {Component, provide, Observable} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
|
||||
// #docregion AsyncPipe
|
||||
@Component({
|
||||
selector: 'async-example',
|
||||
template: `<div>
|
||||
<p>Wait for it... {{ greeting | async }}</p>
|
||||
<button (click)="clicked()">{{ arrived ? 'Reset' : 'Resolve' }}</button>
|
||||
<button (click)="clicked()">{{ arrived ? 'Reset' : 'Resolve' }}</button>
|
||||
</div>`
|
||||
})
|
||||
export class AsyncPipeExample {
|
||||
@ -44,7 +45,7 @@ class Task {
|
||||
@Component({
|
||||
selector: 'example-app',
|
||||
directives: [AsyncPipeExample],
|
||||
template: `
|
||||
template: `
|
||||
<h1>AsyncPipe Example</h1>
|
||||
<async-example></async-example>
|
||||
`
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, provide} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
|
||||
// #docregion DatePipe
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, provide} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
|
||||
// #docregion JsonPipe
|
||||
@ -19,7 +19,7 @@ export class JsonPipeExample {
|
||||
@Component({
|
||||
selector: 'example-app',
|
||||
directives: [JsonPipeExample],
|
||||
template: `
|
||||
template: `
|
||||
<h1>JsonPipe Example</h1>
|
||||
<json-example></json-example>
|
||||
`
|
||||
|
@ -1,11 +1,11 @@
|
||||
import {Component, provide} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
|
||||
// #docregion LowerUpperPipe
|
||||
@Component({
|
||||
selector: 'lowerupper-example',
|
||||
template: `<div>
|
||||
<label>Name: </label><input #name (keyup)="change(name.value)" type="text"></input>
|
||||
<label>Name: </label><input #name (keyup)="change(name.value)" type="text">
|
||||
<p>In lowercase: <pre>'{{value | lowercase}}'</pre></p>
|
||||
<p>In uppercase: <pre>'{{value | uppercase}}'</pre></p>
|
||||
</div>`
|
||||
@ -19,7 +19,7 @@ export class LowerUpperPipeExample {
|
||||
@Component({
|
||||
selector: 'example-app',
|
||||
directives: [LowerUpperPipeExample],
|
||||
template: `
|
||||
template: `
|
||||
<h1>LowercasePipe & UppercasePipe Example</h1>
|
||||
<lowerupper-example></lowerupper-example>
|
||||
`
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, provide} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
|
||||
// #docregion NumberPipe
|
||||
@ -48,7 +48,7 @@ export class CurrencyPipeExample {
|
||||
@Component({
|
||||
selector: 'example-app',
|
||||
directives: [NumberPipeExample, PercentPipeExample, CurrencyPipeExample],
|
||||
template: `
|
||||
template: `
|
||||
<h1>Numeric Pipe Examples</h1>
|
||||
<h2>NumberPipe Example</h2>
|
||||
<number-example></number-example>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Component, provide} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
|
||||
// #docregion SlicePipe_string
|
||||
@ -22,7 +22,7 @@ export class SlicePipeStringExample {
|
||||
@Component({
|
||||
selector: 'slice-list-example',
|
||||
template: `<div>
|
||||
<li *ng-for="var i of collection | slice:1:3">{{i}}</li>
|
||||
<li *ngFor="var i of collection | slice:1:3">{{i}}</li>
|
||||
</div>`
|
||||
})
|
||||
export class SlicePipeListExample {
|
||||
@ -33,7 +33,7 @@ export class SlicePipeListExample {
|
||||
@Component({
|
||||
selector: 'example-app',
|
||||
directives: [SlicePipeListExample, SlicePipeStringExample],
|
||||
template: `
|
||||
template: `
|
||||
<h1>SlicePipe Examples</h1>
|
||||
<slice-list-example></slice-list-example>
|
||||
<slice-string-example></slice-string-example>
|
||||
|
13
modules/angular2/examples/core/ts/bootstrap/bootstrap.ts
Normal file
13
modules/angular2/examples/core/ts/bootstrap/bootstrap.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/platform/browser';
|
||||
|
||||
// #docregion bootstrap
|
||||
@Component({selector: 'my-app', template: 'Hello {{ name }}!'})
|
||||
class MyApp {
|
||||
name: string = 'World';
|
||||
}
|
||||
|
||||
function main() {
|
||||
return bootstrap(MyApp);
|
||||
}
|
||||
// #enddocregion
|
@ -1,7 +0,0 @@
|
||||
// #docregion enableDevMode
|
||||
import {bootstrap, enableDevMode} from 'angular2/angular2';
|
||||
import {MyComponent} from 'my_component';
|
||||
|
||||
enableDevMode();
|
||||
bootstrap(MyComponent);
|
||||
// #enddocregion
|
43
modules/angular2/examples/core/ts/metadata/metadata.ts
Normal file
43
modules/angular2/examples/core/ts/metadata/metadata.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import {Component, Attribute, Directive, Pipe} from 'angular2/core';
|
||||
|
||||
var CustomDirective;
|
||||
|
||||
// #docregion component
|
||||
@Component({selector: 'greet', template: 'Hello {{name}}!', directives: [CustomDirective]})
|
||||
class Greet {
|
||||
name: string = 'World';
|
||||
}
|
||||
// #enddocregion
|
||||
|
||||
// #docregion attributeFactory
|
||||
@Component({selector: 'page', template: 'Title: {{title}}'})
|
||||
class Page {
|
||||
title: string;
|
||||
constructor(@Attribute('title') title: string) { this.title = title; }
|
||||
}
|
||||
// #enddocregion
|
||||
|
||||
// #docregion attributeMetadata
|
||||
@Directive({selector: 'input'})
|
||||
class InputAttrDirective {
|
||||
constructor(@Attribute('type') type) {
|
||||
// type would be 'text' in this example
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
||||
// #docregion directive
|
||||
@Directive({selector: 'input'})
|
||||
class InputDirective {
|
||||
constructor() {
|
||||
// Add some logic.
|
||||
}
|
||||
}
|
||||
// #enddocregion
|
||||
|
||||
// #docregion pipe
|
||||
@Pipe({name: 'lowercase'})
|
||||
class Lowercase {
|
||||
transform(v, args) { return v.toLowerCase(); }
|
||||
}
|
||||
// #enddocregion
|
13
modules/angular2/examples/core/ts/platform/platform.ts
Normal file
13
modules/angular2/examples/core/ts/platform/platform.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import {Component, platform} from 'angular2/core';
|
||||
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
||||
|
||||
var appProviders: any[] = [];
|
||||
|
||||
// #docregion longform
|
||||
@Component({selector: 'my-app', template: 'Hello World'})
|
||||
class MyApp {
|
||||
}
|
||||
|
||||
var app = platform(BROWSER_PROVIDERS).application([BROWSER_APP_PROVIDERS, appProviders]);
|
||||
app.bootstrap(MyApp);
|
||||
// #enddocregion
|
@ -0,0 +1,8 @@
|
||||
// #docregion enableProdMode
|
||||
import {enableProdMode} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {MyComponent} from 'my_component';
|
||||
|
||||
enableProdMode();
|
||||
bootstrap(MyComponent);
|
||||
// #enddocregion
|
8
modules/angular2/examples/facade/ts/async/observable.ts
Normal file
8
modules/angular2/examples/facade/ts/async/observable.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// #docregion Observable
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
var obs = new Observable<number>(obs => {
|
||||
var i = 0;
|
||||
setInterval(_ => { obs.next(++i); }, 1000);
|
||||
});
|
||||
obs.subscribe(i => console.log(`${i} seconds elapsed`));
|
||||
// #enddocregion
|
@ -0,0 +1,3 @@
|
||||
// #docregion Observable
|
||||
import 'rxjs';
|
||||
// #enddocregion
|
@ -0,0 +1,10 @@
|
||||
// #docregion Observable
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
var obs = new Observable(obs => {
|
||||
var i = 0;
|
||||
setInterval(_ => obs.next(++i), 1000);
|
||||
});
|
||||
obs.map(i => `${i} seconds elapsed`).subscribe(msg => console.log(msg));
|
||||
// #enddocregion
|
10
modules/angular2/examples/facade/ts/async/observable_pure.ts
Normal file
10
modules/angular2/examples/facade/ts/async/observable_pure.ts
Normal file
@ -0,0 +1,10 @@
|
||||
// #docregion Observable
|
||||
import {Observable} from 'rxjs/Observable';
|
||||
import {map} from 'rxjs/operator/map';
|
||||
|
||||
var obs = new Observable(obs => {
|
||||
var i = 0;
|
||||
setInterval(_ => obs.next(++i), 1000);
|
||||
});
|
||||
map.call(obs, i => `${i} seconds elapsed`).subscribe(msg => console.log(msg));
|
||||
// #enddocregion
|
17
modules/angular2/examples/platform/dom/debug/ts/by/by.ts
Normal file
17
modules/angular2/examples/platform/dom/debug/ts/by/by.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {By} from 'angular2/platform/browser';
|
||||
import {DebugElement} from 'angular2/core';
|
||||
|
||||
var debugElement: DebugElement;
|
||||
class MyDirective {}
|
||||
|
||||
// #docregion by_all
|
||||
debugElement.query(By.all());
|
||||
// #enddocregion
|
||||
|
||||
// #docregion by_css
|
||||
debugElement.query(By.css('[attribute]'));
|
||||
// #enddocregion
|
||||
|
||||
// #docregion by_directive
|
||||
debugElement.query(By.directive(MyDirective));
|
||||
// #enddocregion
|
@ -0,0 +1,10 @@
|
||||
import {Component} from 'angular2/core';
|
||||
import {bootstrap, ELEMENT_PROBE_PROVIDERS} from 'angular2/platform/browser';
|
||||
|
||||
@Component({selector: 'my-component'})
|
||||
class MyAppComponent {
|
||||
}
|
||||
|
||||
// #docregion providers
|
||||
bootstrap(MyAppComponent, [ELEMENT_PROBE_PROVIDERS]);
|
||||
// #enddocregion
|
@ -1,4 +1,5 @@
|
||||
import {bootstrap, provide, Component} from 'angular2/angular2';
|
||||
import {provide, Component} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {
|
||||
CanActivate,
|
||||
RouteConfig,
|
||||
@ -24,8 +25,8 @@ class ControlPanelCmp {
|
||||
template: `
|
||||
<h1>Welcome Home!</h1>
|
||||
<div>
|
||||
Edit <a [router-link]="['/ControlPanelCmp', {id: 1}]" id="user-1-link">User 1</a> |
|
||||
Edit <a [router-link]="['/ControlPanelCmp', {id: 2}]" id="user-2-link">User 2</a>
|
||||
Edit <a [routerLink]="['/ControlPanelCmp', {id: 1}]" id="user-1-link">User 1</a> |
|
||||
Edit <a [routerLink]="['/ControlPanelCmp', {id: 2}]" id="user-2-link">User 2</a>
|
||||
</div>
|
||||
`,
|
||||
directives: [ROUTER_DIRECTIVES]
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
|
||||
import {Promise} from 'angular2/src/facade/async';
|
||||
|
||||
function waitForElement(selector) {
|
||||
var EC = (<any>protractor).ExpectedConditions;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {provide, bootstrap, Component} from 'angular2/angular2';
|
||||
import {provide, Component} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {
|
||||
CanDeactivate,
|
||||
RouteConfig,
|
||||
@ -34,8 +35,8 @@ class NoteCmp implements CanDeactivate {
|
||||
template: `
|
||||
<h1>Your Notes</h1>
|
||||
<div>
|
||||
Edit <a [router-link]="['/NoteCmp', {id: 1}]" id="note-1-link">Note 1</a> |
|
||||
Edit <a [router-link]="['/NoteCmp', {id: 2}]" id="note-2-link">Note 2</a>
|
||||
Edit <a [routerLink]="['/NoteCmp', {id: 1}]" id="note-1-link">Note 1</a> |
|
||||
Edit <a [routerLink]="['/NoteCmp', {id: 2}]" id="note-2-link">Note 2</a>
|
||||
</div>
|
||||
`,
|
||||
directives: [ROUTER_DIRECTIVES]
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
|
||||
import {Promise} from 'angular2/src/facade/async';
|
||||
|
||||
function waitForElement(selector) {
|
||||
var EC = (<any>protractor).ExpectedConditions;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {Component, provide, bootstrap} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {
|
||||
OnActivate,
|
||||
ComponentInstruction,
|
||||
@ -25,8 +26,8 @@ class MyCmp implements OnActivate {
|
||||
template: `
|
||||
<h1>My App</h1>
|
||||
<nav>
|
||||
<a [router-link]="['/HomeCmp']" id="home-link">Navigate Home</a> |
|
||||
<a [router-link]="['/ParamCmp', {param: 1}]" id="param-link">Navigate with a Param</a>
|
||||
<a [routerLink]="['/HomeCmp']" id="home-link">Navigate Home</a> |
|
||||
<a [routerLink]="['/ParamCmp', {param: 1}]" id="param-link">Navigate with a Param</a>
|
||||
</nav>
|
||||
<router-outlet></router-outlet>
|
||||
`,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
|
||||
import {Promise} from 'angular2/src/facade/async';
|
||||
|
||||
function waitForElement(selector) {
|
||||
var EC = (<any>protractor).ExpectedConditions;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {Component, Injectable, NgFor, provide, bootstrap} from 'angular2/angular2';
|
||||
import {Component, Injectable, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {
|
||||
OnDeactivate,
|
||||
ComponentInstruction,
|
||||
@ -34,16 +35,16 @@ class MyCmp implements OnDeactivate {
|
||||
template: `
|
||||
<h1>My App</h1>
|
||||
<nav>
|
||||
<a [router-link]="['/HomeCmp']" id="home-link">Navigate Home</a> |
|
||||
<a [router-link]="['/ParamCmp', {param: 1}]" id="param-link">Navigate with a Param</a>
|
||||
<a [routerLink]="['/HomeCmp']" id="home-link">Navigate Home</a> |
|
||||
<a [routerLink]="['/ParamCmp', {param: 1}]" id="param-link">Navigate with a Param</a>
|
||||
</nav>
|
||||
<router-outlet></router-outlet>
|
||||
<div id="log">
|
||||
<h2>Log:</h2>
|
||||
<p *ng-for="#logItem of logService.logs">{{ logItem }}</p>
|
||||
<p *ngFor="#logItem of logService.logs">{{ logItem }}</p>
|
||||
</div>
|
||||
`,
|
||||
directives: [ROUTER_DIRECTIVES, NgFor]
|
||||
directives: [ROUTER_DIRECTIVES]
|
||||
})
|
||||
@RouteConfig([
|
||||
{path: '/', component: MyCmp, name: 'HomeCmp'},
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
|
||||
import {Promise} from 'angular2/src/facade/async';
|
||||
|
||||
function waitForElement(selector) {
|
||||
var EC = (<any>protractor).ExpectedConditions;
|
||||
|
@ -1,4 +1,5 @@
|
||||
import {bootstrap, Component, provide} from 'angular2/angular2';
|
||||
import {Component, provide} from 'angular2/core';
|
||||
import {bootstrap} from 'angular2/bootstrap';
|
||||
import {
|
||||
CanActivate,
|
||||
RouteConfig,
|
||||
@ -37,8 +38,8 @@ class MyCmp implements CanReuse,
|
||||
selector: 'example-app',
|
||||
template: `
|
||||
<h1>Say hi to...</h1>
|
||||
<a [router-link]="['/HomeCmp', {name: 'naomi'}]" id="naomi-link">Naomi</a> |
|
||||
<a [router-link]="['/HomeCmp', {name: 'brad'}]" id="brad-link">Brad</a>
|
||||
<a [routerLink]="['/HomeCmp', {name: 'naomi'}]" id="naomi-link">Naomi</a> |
|
||||
<a [routerLink]="['/HomeCmp', {name: 'brad'}]" id="brad-link">Brad</a>
|
||||
<router-outlet></router-outlet>
|
||||
`,
|
||||
directives: [ROUTER_DIRECTIVES]
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {verifyNoBrowserErrors} from 'angular2/src/testing/e2e_util';
|
||||
import {Promise} from 'angular2/src/facade/async';
|
||||
|
||||
function waitForElement(selector) {
|
||||
var EC = (<any>protractor).ExpectedConditions;
|
||||
|
29
modules/angular2/examples/testing/ts/fake_async.ts
Normal file
29
modules/angular2/examples/testing/ts/fake_async.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import {describe, it, fakeAsync, expect, tick, clearPendingTimers} from 'angular2/testing';
|
||||
|
||||
// #docregion basic
|
||||
describe('this test', () => {
|
||||
it('looks async but is synchronous', <any>fakeAsync((): void => {
|
||||
var flag = false;
|
||||
setTimeout(() => { flag = true; }, 100);
|
||||
expect(flag).toBe(false);
|
||||
tick(50);
|
||||
expect(flag).toBe(false);
|
||||
tick(50);
|
||||
expect(flag).toBe(true);
|
||||
}));
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion pending
|
||||
describe('this test', () => {
|
||||
it('aborts a timer', <any>fakeAsync((): void => {
|
||||
// This timer is scheduled but doesn't need to complete for the
|
||||
// test to pass (maybe it's a timeout for some operation).
|
||||
// Leaving it will cause the test to fail...
|
||||
setTimeout(() => {}, 100);
|
||||
|
||||
// Unless we clean it up first.
|
||||
clearPendingTimers();
|
||||
}));
|
||||
});
|
||||
// #enddocregion
|
40
modules/angular2/examples/testing/ts/matchers.ts
Normal file
40
modules/angular2/examples/testing/ts/matchers.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import {expect} from 'angular2/testing';
|
||||
|
||||
var value: any;
|
||||
var element: any;
|
||||
var exception: any;
|
||||
|
||||
abstract class OtherClass {}
|
||||
class SomeClass {}
|
||||
|
||||
// #docregion toBePromise
|
||||
expect(value).toBePromise();
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toBeAnInstanceOf
|
||||
expect(value).toBeAnInstanceOf(SomeClass);
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toHaveText
|
||||
expect(element).toHaveText('Hello world!');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toHaveCssClass
|
||||
expect(element).toHaveCssClass('current');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toHaveCssStyle
|
||||
expect(element).toHaveCssStyle({width: '100px', height: 'auto'});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toContainError
|
||||
expect(exception).toContainError('Failed to load');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toThrowErrorWith
|
||||
expect(() => { throw 'Failed to load'; }).toThrowErrorWith('Failed to load');
|
||||
// #enddocregion
|
||||
|
||||
// #docregion toImplement
|
||||
expect(SomeClass).toImplement(OtherClass);
|
||||
// #enddocregion
|
90
modules/angular2/examples/testing/ts/testing.ts
Normal file
90
modules/angular2/examples/testing/ts/testing.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import {
|
||||
describe,
|
||||
fdescribe,
|
||||
xdescribe,
|
||||
it,
|
||||
fit,
|
||||
xit,
|
||||
beforeEach,
|
||||
afterEach,
|
||||
beforeEachProviders,
|
||||
inject
|
||||
} from 'angular2/testing';
|
||||
import {provide} from 'angular2/core';
|
||||
|
||||
var db: any;
|
||||
class MyService {}
|
||||
class MyMockService implements MyService {}
|
||||
|
||||
// #docregion describeIt
|
||||
describe('some component', () => {
|
||||
it('does something', () => {
|
||||
// This is a test.
|
||||
});
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion fdescribe
|
||||
fdescribe('some component', () => {
|
||||
it('has a test', () => {
|
||||
// This test will run.
|
||||
});
|
||||
});
|
||||
describe('another component',
|
||||
() => { it('also has a test', () => { throw 'This test will not run.'; }); });
|
||||
// #enddocregion
|
||||
|
||||
// #docregion xdescribe
|
||||
xdescribe('some component', () => { it('has a test', () => {throw 'This test will not run.'}); });
|
||||
describe('another component', () => {
|
||||
it('also has a test', () => {
|
||||
// This test will run.
|
||||
});
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion fit
|
||||
describe('some component', () => {
|
||||
fit('has a test', () => {
|
||||
// This test will run.
|
||||
});
|
||||
it('has another test', () => { throw 'This test will not run.'; });
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion xit
|
||||
describe('some component', () => {
|
||||
xit('has a test', () => { throw 'This test will not run.'; });
|
||||
it('has another test', () => {
|
||||
// This test will run.
|
||||
});
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion beforeEach
|
||||
describe('some component', () => {
|
||||
beforeEach(() => { db.connect(); });
|
||||
it('uses the db', () => {
|
||||
// Database is connected.
|
||||
});
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion beforeEachProviders
|
||||
describe('some component', () => {
|
||||
beforeEachProviders(() => [provide(MyService, {useClass: MyMockService})]);
|
||||
it('uses MyService', inject([MyService], (service) => {
|
||||
// service is an instance of MyMockService.
|
||||
}));
|
||||
});
|
||||
// #enddocregion
|
||||
|
||||
// #docregion afterEach
|
||||
describe('some component', () => {
|
||||
afterEach((done) => { db.reset().then((_) => done()); });
|
||||
it('uses the db', () => {
|
||||
// This test can leave the database in a dirty state.
|
||||
// The afterEach will ensure it gets reset.
|
||||
});
|
||||
});
|
||||
// #enddocregion
|
@ -44,7 +44,9 @@ export {URLSearchParams} from './src/http/url_search_params';
|
||||
* ### Example ([live demo](http://plnkr.co/edit/snj7Nv?p=preview))
|
||||
*
|
||||
* ```
|
||||
* import {bootstrap, Component, NgFor, View} from 'angular2/angular2';
|
||||
* import {Component} from 'angular2/core';
|
||||
* import {bootstrap} from 'angular2/platform/browser';
|
||||
* import {NgFor} from 'angular2/common';
|
||||
* import {HTTP_PROVIDERS, Http} from 'angular2/http';
|
||||
*
|
||||
* @Component({
|
||||
@ -54,7 +56,7 @@ export {URLSearchParams} from './src/http/url_search_params';
|
||||
* <div>
|
||||
* <h1>People</h1>
|
||||
* <ul>
|
||||
* <li *ng-for="#person of people">
|
||||
* <li *ngFor="#person of people">
|
||||
* {{person.name}}
|
||||
* </li>
|
||||
* </ul>
|
||||
@ -98,7 +100,8 @@ export {URLSearchParams} from './src/http/url_search_params';
|
||||
* ### Example ([live demo](http://plnkr.co/edit/aCMEXi?p=preview))
|
||||
*
|
||||
* ```
|
||||
* import {provide, bootstrap} from 'angular2/angular2';
|
||||
* import {provide} from 'angular2/core';
|
||||
* import {bootstrap} from 'angular2/platform/browser';
|
||||
* import {HTTP_PROVIDERS, BaseRequestOptions, RequestOptions} from 'angular2/http';
|
||||
*
|
||||
* class MyOptions extends BaseRequestOptions {
|
||||
@ -115,7 +118,8 @@ export {URLSearchParams} from './src/http/url_search_params';
|
||||
* ### Example ([live demo](http://plnkr.co/edit/7LWALD?p=preview))
|
||||
*
|
||||
* ```
|
||||
* import {provide, Injector} from 'angular2/angular2';
|
||||
* import {provide} from 'angular2/core';
|
||||
* import {bootstrap} from 'angular2/platform/browser';
|
||||
* import {HTTP_PROVIDERS, Http, Response, XHRBackend} from 'angular2/http';
|
||||
* import {MockBackend} from 'angular2/http/testing';
|
||||
*
|
||||
@ -137,7 +141,8 @@ export {URLSearchParams} from './src/http/url_search_params';
|
||||
* // Send a response to the request
|
||||
* connection.mockRespond(response);
|
||||
* });
|
||||
* });
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* http.get('people.json').observer({
|
||||
* next: res => {
|
||||
@ -152,7 +157,8 @@ export const HTTP_PROVIDERS: any[] = [
|
||||
// issue: https://github.com/angular/angular/issues/3183
|
||||
provide(Http,
|
||||
{
|
||||
useFactory: (xhrBackend, requestOptions) => new Http(xhrBackend, requestOptions),
|
||||
useFactory: (xhrBackend: XHRBackend, requestOptions: RequestOptions) =>
|
||||
new Http(xhrBackend, requestOptions),
|
||||
deps: [XHRBackend, RequestOptions]
|
||||
}),
|
||||
BrowserXhr,
|
||||
@ -162,6 +168,8 @@ export const HTTP_PROVIDERS: any[] = [
|
||||
];
|
||||
|
||||
/**
|
||||
* See {@link HTTP_PROVIDERS} instead.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
export const HTTP_BINDINGS = HTTP_PROVIDERS;
|
||||
@ -175,7 +183,8 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
|
||||
* ### Example ([live demo](http://plnkr.co/edit/vmeN4F?p=preview))
|
||||
*
|
||||
* ```
|
||||
* import {Component, NgFor, View} from 'angular2/angular2';
|
||||
* import {Component} from 'angular2/core';
|
||||
* import {NgFor} from 'angular2/common';
|
||||
* import {JSONP_PROVIDERS, Jsonp} from 'angular2/http';
|
||||
*
|
||||
* @Component({
|
||||
@ -185,7 +194,7 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
|
||||
* <div>
|
||||
* <h1>People</h1>
|
||||
* <ul>
|
||||
* <li *ng-for="#person of people">
|
||||
* <li *ngFor="#person of people">
|
||||
* {{person.name}}
|
||||
* </li>
|
||||
* </ul>
|
||||
@ -222,7 +231,8 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
|
||||
* ### Example ([live demo](http://plnkr.co/edit/TFug7x?p=preview))
|
||||
*
|
||||
* ```
|
||||
* import {provide, bootstrap} from 'angular2/angular2';
|
||||
* import {provide} from 'angular2/core';
|
||||
* import {bootstrap} from 'angular2/platform/browser';
|
||||
* import {JSONP_PROVIDERS, BaseRequestOptions, RequestOptions} from 'angular2/http';
|
||||
*
|
||||
* class MyOptions extends BaseRequestOptions {
|
||||
@ -239,7 +249,7 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
|
||||
* ### Example ([live demo](http://plnkr.co/edit/HDqZWL?p=preview))
|
||||
*
|
||||
* ```
|
||||
* import {provide, Injector} from 'angular2/angular2';
|
||||
* import {provide, Injector} from 'angular2/core';
|
||||
* import {JSONP_PROVIDERS, Jsonp, Response, JSONPBackend} from 'angular2/http';
|
||||
* import {MockBackend} from 'angular2/http/testing';
|
||||
*
|
||||
@ -260,7 +270,8 @@ export const HTTP_BINDINGS = HTTP_PROVIDERS;
|
||||
* // Send a response to the request
|
||||
* connection.mockRespond(response);
|
||||
* });
|
||||
* });
|
||||
* }
|
||||
* });
|
||||
|
||||
* jsonp.get('people.json').observer({
|
||||
* next: res => {
|
||||
@ -275,7 +286,8 @@ export const JSONP_PROVIDERS: any[] = [
|
||||
// issue: https://github.com/angular/angular/issues/3183
|
||||
provide(Jsonp,
|
||||
{
|
||||
useFactory: (jsonpBackend, requestOptions) => new Jsonp(jsonpBackend, requestOptions),
|
||||
useFactory: (jsonpBackend: JSONPBackend, requestOptions: RequestOptions) =>
|
||||
new Jsonp(jsonpBackend, requestOptions),
|
||||
deps: [JSONPBackend, RequestOptions]
|
||||
}),
|
||||
BrowserJsonp,
|
||||
@ -285,6 +297,8 @@ export const JSONP_PROVIDERS: any[] = [
|
||||
];
|
||||
|
||||
/**
|
||||
* See {@link JSONP_PROVIDERS} instead.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
export const JSON_BINDINGS = JSONP_PROVIDERS;
|
||||
|
38
modules/angular2/manual_typings/globals-es6.d.ts
vendored
38
modules/angular2/manual_typings/globals-es6.d.ts
vendored
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* Declarations angular depends on for compilation to ES6.
|
||||
* This file is also used to propagate our transitive typings
|
||||
* to users.
|
||||
*/
|
||||
|
||||
/// <reference path="../typings/zone/zone.d.ts"/>
|
||||
/// <reference path="../typings/hammerjs/hammerjs.d.ts"/>
|
||||
/// <reference path="../typings/jasmine/jasmine.d.ts"/>
|
||||
/// <reference path="../typings/angular-protractor/angular-protractor.d.ts"/>
|
||||
|
||||
// TODO: ideally the node.d.ts reference should be scoped only for files that need and not to all
|
||||
// the code including client code
|
||||
/// <reference path="../typings/node/node.d.ts" />
|
||||
|
||||
declare var assert: any;
|
||||
|
||||
|
||||
interface BrowserNodeGlobal {
|
||||
Object: typeof Object;
|
||||
Array: typeof Array;
|
||||
Map: typeof Map;
|
||||
Set: typeof Set;
|
||||
Date: typeof Date;
|
||||
RegExp: typeof RegExp;
|
||||
JSON: typeof JSON;
|
||||
Math: typeof Math;
|
||||
assert(condition: any): void;
|
||||
Reflect: any;
|
||||
zone: Zone;
|
||||
getAngularTestability: Function;
|
||||
getAllAngularTestabilities: Function;
|
||||
angularDevMode: boolean;
|
||||
setTimeout: Function;
|
||||
clearTimeout: Function;
|
||||
setInterval: Function;
|
||||
clearInterval: Function;
|
||||
}
|
55
modules/angular2/manual_typings/globals.d.ts
vendored
55
modules/angular2/manual_typings/globals.d.ts
vendored
@ -1,7 +1,52 @@
|
||||
/**
|
||||
* Declarations angular depends on for compilation to ES6.
|
||||
* This file is also used to propagate our transitive typings
|
||||
* to users.
|
||||
* Subset of es6-shim typings.
|
||||
* Angular should not require use of ES6 runtime but some API usages are already present.
|
||||
* See https://github.com/angular/angular/issues/5242
|
||||
* TODO(alexeagle): remove methods below which may not be present in targeted browser
|
||||
*/
|
||||
/// <reference path="../typings/es6-shim/es6-shim.d.ts"/>
|
||||
/// <reference path="./globals-es6.d.ts"/>
|
||||
|
||||
declare type PromiseConstructor = typeof Promise;
|
||||
|
||||
interface String {
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* position. Otherwise returns false.
|
||||
*/
|
||||
startsWith(searchString: string, position?: number): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the sequence of elements of searchString converted to a String is the
|
||||
* same as the corresponding elements of this object (converted to a String) starting at
|
||||
* endPosition – length(this). Otherwise returns false.
|
||||
*/
|
||||
endsWith(searchString: string, endPosition?: number): boolean;
|
||||
}
|
||||
interface Array<T> {
|
||||
/**
|
||||
* Returns the value of the first element in the array where predicate is true, and undefined
|
||||
* otherwise.
|
||||
* @param predicate find calls predicate once for each element of the array, in ascending
|
||||
* order, until it finds one where predicate returns true. If such an element is found, find
|
||||
* immediately returns that element value. Otherwise, find returns undefined.
|
||||
* @param thisArg If provided, it will be used as the this value for each invocation of
|
||||
* predicate. If it is not provided, undefined is used instead.
|
||||
*/
|
||||
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): T;
|
||||
/**
|
||||
* Returns the this object after filling the section identified by start and end with value
|
||||
* @param value value to fill array section with
|
||||
* @param start index to start filling the array at. If start is negative, it is treated as
|
||||
* length+start where length is the length of the array.
|
||||
* @param end index to stop filling the array at. If end is negative, it is treated as
|
||||
* length+end.
|
||||
*/
|
||||
fill(value: T, start?: number, end?: number): T[];
|
||||
}
|
||||
interface NumberConstructor {
|
||||
/**
|
||||
* Returns true if the value passed is an integer, false otherwise.
|
||||
* @param number A numeric value.
|
||||
*/
|
||||
isInteger(number: number): boolean;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
|
||||
export {
|
||||
BROWSER_PROVIDERS,
|
||||
ELEMENT_PROBE_BINDINGS,
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
ELEMENT_PROBE_PROVIDERS_PROD_MODE,
|
||||
inspectNativeElement,
|
||||
BrowserDomAdapter,
|
||||
By,
|
||||
@ -13,7 +13,6 @@ export {
|
||||
} from 'angular2/src/platform/browser_common';
|
||||
|
||||
import {Type, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
import {Promise} from 'angular2/src/facade/promise';
|
||||
import {
|
||||
BROWSER_PROVIDERS,
|
||||
BROWSER_APP_COMMON_PROVIDERS
|
||||
@ -62,23 +61,7 @@ export const BROWSER_APP_PROVIDERS: Array<any /*Type | Provider | any[]*/> = CON
|
||||
*
|
||||
* We can use this script code:
|
||||
*
|
||||
* ```
|
||||
* @Component({
|
||||
* selector: 'my-app',
|
||||
* template: 'Hello {{ name }}!'
|
||||
* })
|
||||
* class MyApp {
|
||||
* name:string;
|
||||
*
|
||||
* constructor() {
|
||||
* this.name = 'World';
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* main() {
|
||||
* return bootstrap(MyApp);
|
||||
* }
|
||||
* ```
|
||||
* {@example core/ts/bootstrap/bootstrap.ts region='bootstrap'}
|
||||
*
|
||||
* When the app developer invokes `bootstrap()` with the root component `MyApp` as its
|
||||
* argument, Angular performs the following tasks:
|
||||
|
@ -1,8 +1,8 @@
|
||||
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
|
||||
export {
|
||||
BROWSER_PROVIDERS,
|
||||
ELEMENT_PROBE_BINDINGS,
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
ELEMENT_PROBE_PROVIDERS_PROD_MODE,
|
||||
inspectNativeElement,
|
||||
BrowserDomAdapter,
|
||||
By,
|
||||
@ -12,7 +12,6 @@ export {
|
||||
} from 'angular2/src/platform/browser_common';
|
||||
|
||||
import {Type, isPresent} from 'angular2/src/facade/lang';
|
||||
import {Promise} from 'angular2/src/facade/promise';
|
||||
import {
|
||||
BROWSER_PROVIDERS,
|
||||
BROWSER_APP_COMMON_PROVIDERS
|
||||
|
@ -12,4 +12,4 @@ export {
|
||||
EventManagerPlugin
|
||||
} from 'angular2/src/platform/dom/events/event_manager';
|
||||
export * from 'angular2/src/platform/dom/debug/by';
|
||||
export * from 'angular2/src/platform/dom/debug/debug_element_view_listener';
|
||||
export * from 'angular2/src/platform/dom/debug/ng_probe';
|
||||
|
21
modules/angular2/platform/testing/browser.ts
Normal file
21
modules/angular2/platform/testing/browser.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import {
|
||||
TEST_BROWSER_STATIC_PLATFORM_PROVIDERS,
|
||||
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
||||
} from 'angular2/platform/testing/browser_static';
|
||||
|
||||
import {BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
|
||||
|
||||
|
||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
|
||||
/**
|
||||
* Default patform providers for testing.
|
||||
*/
|
||||
export const TEST_BROWSER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([TEST_BROWSER_STATIC_PLATFORM_PROVIDERS]);
|
||||
|
||||
/**
|
||||
* Default application providers for testing.
|
||||
*/
|
||||
export const TEST_BROWSER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([BROWSER_APP_PROVIDERS, ADDITIONAL_TEST_BROWSER_PROVIDERS]);
|
69
modules/angular2/platform/testing/browser_static.ts
Normal file
69
modules/angular2/platform/testing/browser_static.ts
Normal file
@ -0,0 +1,69 @@
|
||||
import {
|
||||
APP_ID,
|
||||
DirectiveResolver,
|
||||
NgZone,
|
||||
Provider,
|
||||
ViewResolver,
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
PLATFORM_INITIALIZER
|
||||
} from 'angular2/core';
|
||||
import {BROWSER_APP_COMMON_PROVIDERS} from 'angular2/src/platform/browser_common';
|
||||
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
|
||||
|
||||
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
|
||||
import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock';
|
||||
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
||||
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
||||
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
||||
import {LocationStrategy} from 'angular2/src/router/location_strategy';
|
||||
import {MockNgZone} from 'angular2/src/mock/ng_zone_mock';
|
||||
|
||||
import {XHRImpl} from "angular2/src/platform/browser/xhr_impl";
|
||||
import {XHR} from 'angular2/compiler';
|
||||
|
||||
import {TestComponentBuilder} from 'angular2/src/testing/test_component_builder';
|
||||
|
||||
import {BrowserDetection} from 'angular2/src/testing/utils';
|
||||
|
||||
import {ELEMENT_PROBE_PROVIDERS} from 'angular2/platform/common_dom';
|
||||
|
||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
|
||||
import {Log} from 'angular2/src/testing/utils';
|
||||
|
||||
function initBrowserTests() {
|
||||
BrowserDomAdapter.makeCurrent();
|
||||
BrowserDetection.setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default patform providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
new Provider(PLATFORM_INITIALIZER, {useValue: initBrowserTests, multi: true})
|
||||
]);
|
||||
|
||||
export const ADDITIONAL_TEST_BROWSER_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([
|
||||
new Provider(APP_ID, {useValue: 'a'}),
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
new Provider(DirectiveResolver, {useClass: MockDirectiveResolver}),
|
||||
new Provider(ViewResolver, {useClass: MockViewResolver}),
|
||||
Log,
|
||||
TestComponentBuilder,
|
||||
new Provider(NgZone, {useClass: MockNgZone}),
|
||||
new Provider(LocationStrategy, {useClass: MockLocationStrategy}),
|
||||
new Provider(AnimationBuilder, {useClass: MockAnimationBuilder}),
|
||||
]);
|
||||
|
||||
/**
|
||||
* Default application providers for testing without a compiler.
|
||||
*/
|
||||
export const TEST_BROWSER_STATIC_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([
|
||||
BROWSER_APP_COMMON_PROVIDERS,
|
||||
new Provider(XHR, {useClass: XHRImpl}),
|
||||
ADDITIONAL_TEST_BROWSER_PROVIDERS
|
||||
]);
|
1
modules/angular2/platform/testing/server.dart
Normal file
1
modules/angular2/platform/testing/server.dart
Normal file
@ -0,0 +1 @@
|
||||
// Intentionally blank, the Parse5Adapater bindings for JavaScript don't apply.
|
90
modules/angular2/platform/testing/server.ts
Normal file
90
modules/angular2/platform/testing/server.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import {
|
||||
APP_ID,
|
||||
DirectiveResolver,
|
||||
NgZone,
|
||||
Provider,
|
||||
ViewResolver,
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
PLATFORM_INITIALIZER,
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
Renderer
|
||||
} from 'angular2/core';
|
||||
import {Parse5DomAdapter} from 'angular2/src/platform/server/parse5_adapter';
|
||||
|
||||
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
|
||||
import {MockAnimationBuilder} from 'angular2/src/mock/animation_builder_mock';
|
||||
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
|
||||
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
|
||||
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
|
||||
import {LocationStrategy} from 'angular2/src/router/location_strategy';
|
||||
import {MockNgZone} from 'angular2/src/mock/ng_zone_mock';
|
||||
|
||||
import {TestComponentBuilder} from 'angular2/src/testing/test_component_builder';
|
||||
import {XHR} from 'angular2/src/compiler/xhr';
|
||||
import {BrowserDetection} from 'angular2/src/testing/utils';
|
||||
|
||||
import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
|
||||
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
|
||||
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
|
||||
import {RootRenderer} from 'angular2/src/core/render/api';
|
||||
import {DomRootRenderer, DomRootRenderer_} from 'angular2/src/platform/dom/dom_renderer';
|
||||
import {DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
|
||||
|
||||
import {
|
||||
EventManager,
|
||||
EVENT_MANAGER_PLUGINS,
|
||||
ELEMENT_PROBE_PROVIDERS
|
||||
} from 'angular2/platform/common_dom';
|
||||
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
|
||||
|
||||
import {CONST_EXPR} from 'angular2/src/facade/lang';
|
||||
|
||||
import {Log} from 'angular2/src/testing/utils';
|
||||
|
||||
function initServerTests() {
|
||||
Parse5DomAdapter.makeCurrent();
|
||||
BrowserDetection.setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default patform providers for testing.
|
||||
*/
|
||||
export const TEST_SERVER_PLATFORM_PROVIDERS: Array<any /*Type | Provider | any[]*/> = CONST_EXPR([
|
||||
PLATFORM_COMMON_PROVIDERS,
|
||||
new Provider(PLATFORM_INITIALIZER, {useValue: initServerTests, multi: true})
|
||||
]);
|
||||
|
||||
function appDoc() {
|
||||
try {
|
||||
return DOM.defaultDoc();
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default application providers for testing.
|
||||
*/
|
||||
export const TEST_SERVER_APPLICATION_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
|
||||
CONST_EXPR([
|
||||
// TODO(julie): when angular2/platform/server is available, use that instead of making our own
|
||||
// list here.
|
||||
APPLICATION_COMMON_PROVIDERS,
|
||||
COMPILER_PROVIDERS,
|
||||
new Provider(DOCUMENT, {useFactory: appDoc}),
|
||||
new Provider(DomRootRenderer, {useClass: DomRootRenderer_}),
|
||||
new Provider(RootRenderer, {useExisting: DomRootRenderer}),
|
||||
EventManager,
|
||||
new Provider(EVENT_MANAGER_PLUGINS, {useClass: DomEventsPlugin, multi: true}),
|
||||
new Provider(XHR, {useClass: XHR}),
|
||||
new Provider(APP_ID, {useValue: 'a'}),
|
||||
DomSharedStylesHost,
|
||||
ELEMENT_PROBE_PROVIDERS,
|
||||
new Provider(DirectiveResolver, {useClass: MockDirectiveResolver}),
|
||||
new Provider(ViewResolver, {useClass: MockViewResolver}),
|
||||
Log,
|
||||
TestComponentBuilder,
|
||||
new Provider(NgZone, {useClass: MockNgZone}),
|
||||
new Provider(LocationStrategy, {useClass: MockLocationStrategy}),
|
||||
new Provider(AnimationBuilder, {useClass: MockAnimationBuilder}),
|
||||
]);
|
16
modules/angular2/platform/worker_app.dart
Normal file
16
modules/angular2/platform/worker_app.dart
Normal file
@ -0,0 +1,16 @@
|
||||
library angular2.platform.worker_app;
|
||||
|
||||
export "package:angular2/src/platform/worker_app_common.dart"
|
||||
show WORKER_APP_PLATFORM, WORKER_APP_APPLICATION_COMMON;
|
||||
export "package:angular2/src/core/angular_entrypoint.dart"
|
||||
show AngularEntrypoint;
|
||||
export "package:angular2/src/platform/worker_app.dart"
|
||||
show WORKER_APP_APPLICATION, RENDER_SEND_PORT;
|
||||
export 'package:angular2/src/web_workers/shared/client_message_broker.dart'
|
||||
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
|
||||
export 'package:angular2/src/web_workers/shared/service_message_broker.dart'
|
||||
show ReceivedMessage, ServiceMessageBroker, ServiceMessageBrokerFactory;
|
||||
export 'package:angular2/src/web_workers/shared/serializer.dart' show PRIMITIVE;
|
||||
export 'package:angular2/src/web_workers/shared/message_bus.dart';
|
||||
export 'package:angular2/src/web_workers/worker/router_providers.dart'
|
||||
show WORKER_APP_ROUTER;
|
@ -1,19 +1,20 @@
|
||||
export {
|
||||
WORKER_APP_PLATFORM,
|
||||
genericWorkerAppProviders
|
||||
WORKER_APP_APPLICATION_COMMON
|
||||
} from 'angular2/src/platform/worker_app_common';
|
||||
export * from 'angular2/src/platform/worker_app';
|
||||
export {WORKER_APP_APPLICATION} from 'angular2/src/platform/worker_app';
|
||||
export {
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory,
|
||||
FnArg,
|
||||
UiArguments
|
||||
} from '../src/web_workers/shared/client_message_broker';
|
||||
} from 'angular2/src/web_workers/shared/client_message_broker';
|
||||
export {
|
||||
ReceivedMessage,
|
||||
ServiceMessageBroker,
|
||||
ServiceMessageBrokerFactory
|
||||
} from '../src/web_workers/shared/service_message_broker';
|
||||
export {PRIMITIVE} from '../src/web_workers/shared/serializer';
|
||||
export * from '../src/web_workers/shared/message_bus';
|
||||
} from 'angular2/src/web_workers/shared/service_message_broker';
|
||||
export {PRIMITIVE} from 'angular2/src/web_workers/shared/serializer';
|
||||
export * from 'angular2/src/web_workers/shared/message_bus';
|
||||
export {AngularEntrypoint} from 'angular2/src/core/angular_entrypoint';
|
||||
export {WORKER_APP_ROUTER} from 'angular2/src/web_workers/worker/router_providers';
|
||||
|
@ -4,11 +4,11 @@ export 'package:angular2/src/platform/worker_render_common.dart'
|
||||
show
|
||||
WORKER_SCRIPT,
|
||||
WORKER_RENDER_PLATFORM,
|
||||
WORKER_RENDER_APP_COMMON,
|
||||
WORKER_RENDER_APPLICATION_COMMON,
|
||||
initializeGenericWorkerRenderer;
|
||||
|
||||
export 'package:angular2/src/platform/worker_render.dart'
|
||||
show WORKER_RENDER_APP, initIsolate, WebWorkerInstance;
|
||||
show WORKER_RENDER_APPLICATION, initIsolate, WebWorkerInstance;
|
||||
|
||||
export '../src/web_workers/shared/client_message_broker.dart'
|
||||
show ClientMessageBroker, ClientMessageBrokerFactory, FnArg, UiArguments;
|
||||
@ -18,3 +18,9 @@ export '../src/web_workers/shared/service_message_broker.dart'
|
||||
|
||||
export '../src/web_workers/shared/serializer.dart' show PRIMITIVE;
|
||||
export '../src/web_workers/shared/message_bus.dart';
|
||||
export '../src/web_workers/ui/router_providers.dart' show WORKER_RENDER_ROUTER;
|
||||
|
||||
import 'package:angular2/src/platform/worker_render_common.dart';
|
||||
|
||||
const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION_COMMON;
|
||||
|
||||
|
@ -2,9 +2,9 @@ export {
|
||||
WORKER_SCRIPT,
|
||||
WORKER_RENDER_PLATFORM,
|
||||
initializeGenericWorkerRenderer,
|
||||
WORKER_RENDER_APP_COMMON
|
||||
WORKER_RENDER_APPLICATION_COMMON
|
||||
} from 'angular2/src/platform/worker_render_common';
|
||||
export * from 'angular2/src/platform/worker_render';
|
||||
export {WORKER_RENDER_APPLICATION, WebWorkerInstance} from 'angular2/src/platform/worker_render';
|
||||
export {
|
||||
ClientMessageBroker,
|
||||
ClientMessageBrokerFactory,
|
||||
@ -18,3 +18,10 @@ export {
|
||||
} from '../src/web_workers/shared/service_message_broker';
|
||||
export {PRIMITIVE} from '../src/web_workers/shared/serializer';
|
||||
export * from '../src/web_workers/shared/message_bus';
|
||||
import {WORKER_RENDER_APPLICATION} from 'angular2/src/platform/worker_render';
|
||||
|
||||
/**
|
||||
* @deprecated Use WORKER_RENDER_APPLICATION
|
||||
*/
|
||||
export const WORKER_RENDER_APP = WORKER_RENDER_APPLICATION;
|
||||
export {WORKER_RENDER_ROUTER} from 'angular2/src/web_workers/ui/router_providers';
|
||||
|
@ -9,9 +9,8 @@ homepage: <%= packageJson.homepage %>
|
||||
environment:
|
||||
sdk: '>=1.10.0 <2.0.0'
|
||||
dependencies:
|
||||
analyzer: '>=0.24.4 <0.27.0'
|
||||
analyzer: '>=0.24.4 <0.28.0'
|
||||
barback: '^0.15.2+2'
|
||||
code_transformers: '0.2.9+4'
|
||||
dart_style: '>=0.1.8 <0.3.0'
|
||||
glob: '^1.0.0'
|
||||
html: '^0.12.0'
|
||||
@ -19,11 +18,13 @@ dependencies:
|
||||
logging: '>=0.9.0 <0.12.0'
|
||||
observe: '^0.13.1'
|
||||
protobuf: '^0.5.0'
|
||||
quiver: '^0.21.4'
|
||||
source_span: '^1.0.0'
|
||||
stack_trace: '^1.1.1'
|
||||
dev_dependencies:
|
||||
code_transformers: '>=0.2.9+4 <0.4.0'
|
||||
guinness: '^0.1.18'
|
||||
quiver: '^0.21.4'
|
||||
test: '^0.12.6'
|
||||
transformers:
|
||||
- angular2
|
||||
- $dart2js:
|
||||
|
@ -20,18 +20,12 @@ export {OnActivate, OnDeactivate, OnReuse, CanDeactivate, CanReuse} from './src/
|
||||
export {CanActivate} from './src/router/lifecycle_annotations';
|
||||
export {Instruction, ComponentInstruction} from './src/router/instruction';
|
||||
export {OpaqueToken} from 'angular2/core';
|
||||
export {ROUTER_PROVIDERS_COMMON} from 'angular2/src/router/router_providers_common';
|
||||
export {ROUTER_PROVIDERS, ROUTER_BINDINGS} from 'angular2/src/router/router_providers';
|
||||
|
||||
import {PlatformLocation} from './src/router/platform_location';
|
||||
import {LocationStrategy} from './src/router/location_strategy';
|
||||
import {PathLocationStrategy} from './src/router/path_location_strategy';
|
||||
import {Router, RootRouter} from './src/router/router';
|
||||
import {RouterOutlet} from './src/router/router_outlet';
|
||||
import {RouterLink} from './src/router/router_link';
|
||||
import {RouteRegistry, ROUTER_PRIMARY_COMPONENT} from './src/router/route_registry';
|
||||
import {Location} from './src/router/location';
|
||||
import {ApplicationRef, provide, OpaqueToken, Provider} from 'angular2/core';
|
||||
import {CONST_EXPR} from './src/facade/lang';
|
||||
import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
|
||||
/**
|
||||
* A list of directives. To use the router directives like {@link RouterOutlet} and
|
||||
@ -41,7 +35,7 @@ import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
* ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))
|
||||
*
|
||||
* ```
|
||||
* import {Component} from 'angular2/angular2';
|
||||
* import {Component} from 'angular2/core';
|
||||
* import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
||||
*
|
||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||
@ -56,61 +50,3 @@ import {BaseException} from 'angular2/src/facade/exceptions';
|
||||
* ```
|
||||
*/
|
||||
export const ROUTER_DIRECTIVES: any[] = CONST_EXPR([RouterOutlet, RouterLink]);
|
||||
|
||||
/**
|
||||
* A list of {@link Provider}s. To use the router, you must add this to your application.
|
||||
*
|
||||
* ### Example ([live demo](http://plnkr.co/edit/iRUP8B5OUbxCWQ3AcIDm))
|
||||
*
|
||||
* ```
|
||||
* import {Component} from 'angular2/angular2';
|
||||
* import {
|
||||
* ROUTER_DIRECTIVES,
|
||||
* ROUTER_PROVIDERS,
|
||||
* RouteConfig
|
||||
* } from 'angular2/router';
|
||||
*
|
||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||
* @RouteConfig([
|
||||
* {...},
|
||||
* ])
|
||||
* class AppCmp {
|
||||
* // ...
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, [ROUTER_PROVIDERS]);
|
||||
* ```
|
||||
*/
|
||||
export const ROUTER_PROVIDERS: any[] = CONST_EXPR([
|
||||
RouteRegistry,
|
||||
CONST_EXPR(new Provider(LocationStrategy, {useClass: PathLocationStrategy})),
|
||||
PlatformLocation,
|
||||
Location,
|
||||
CONST_EXPR(new Provider(
|
||||
Router,
|
||||
{
|
||||
useFactory: routerFactory,
|
||||
deps: CONST_EXPR([RouteRegistry, Location, ROUTER_PRIMARY_COMPONENT, ApplicationRef])
|
||||
})),
|
||||
CONST_EXPR(new Provider(
|
||||
ROUTER_PRIMARY_COMPONENT,
|
||||
{useFactory: routerPrimaryComponentFactory, deps: CONST_EXPR([ApplicationRef])}))
|
||||
]);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const ROUTER_BINDINGS = ROUTER_PROVIDERS;
|
||||
|
||||
function routerFactory(registry, location, primaryComponent, appRef) {
|
||||
var rootRouter = new RootRouter(registry, location, primaryComponent);
|
||||
appRef.registerDisposeListener(() => rootRouter.dispose());
|
||||
return rootRouter;
|
||||
}
|
||||
|
||||
function routerPrimaryComponentFactory(app) {
|
||||
if (app.componentTypes.length == 0) {
|
||||
throw new BaseException("Bootstrap at least one component before injecting Router.");
|
||||
}
|
||||
return app.componentTypes[0];
|
||||
}
|
||||
|
@ -31,5 +31,5 @@ export {RouterLinkTransform} from 'angular2/src/router/router_link_transform';
|
||||
* <a [routerLink]="User[Modal]"> <!-- Same as <a [routerLink]="['User', ['Modal']]"> -->
|
||||
* ```
|
||||
*/
|
||||
const ROUTER_LINK_DSL_PROVIDER =
|
||||
CONST_EXPR(new Provider(TEMPLATE_TRANSFORMS, {useClass: RouterLinkTransform, multi: true}));
|
||||
export const ROUTER_LINK_DSL_PROVIDER =
|
||||
CONST_EXPR(new Provider(TEMPLATE_TRANSFORMS, {useClass: RouterLinkTransform, multi: true}));
|
||||
|
@ -17,7 +17,7 @@ import {CORE_DIRECTIVES} from './directives';
|
||||
*
|
||||
* ```typescript
|
||||
* import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault, NgModel, NgForm} from
|
||||
* 'angular2/angular2';
|
||||
* 'angular2/common';
|
||||
* import {OtherDirective} from './myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
@ -33,7 +33,7 @@ import {CORE_DIRECTIVES} from './directives';
|
||||
* one could import all the common directives at once:
|
||||
*
|
||||
* ```typescript
|
||||
* import {COMMON_DIRECTIVES} from 'angular2/angular2';
|
||||
* import {COMMON_DIRECTIVES} from 'angular2/common';
|
||||
* import {OtherDirective} from './myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
@ -46,4 +46,4 @@ import {CORE_DIRECTIVES} from './directives';
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export const COMMON_DIRECTIVES: Type[][] = CONST_EXPR([CORE_DIRECTIVES, FORM_DIRECTIVES]);
|
||||
export const COMMON_DIRECTIVES: Type[][] = CONST_EXPR([CORE_DIRECTIVES, FORM_DIRECTIVES]);
|
||||
|
@ -17,7 +17,7 @@ import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './ng_switch';
|
||||
* Instead of writing:
|
||||
*
|
||||
* ```typescript
|
||||
* import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/angular2';
|
||||
* import {NgClass, NgIf, NgFor, NgSwitch, NgSwitchWhen, NgSwitchDefault} from 'angular2/common';
|
||||
* import {OtherDirective} from './myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
@ -32,7 +32,7 @@ import {NgSwitch, NgSwitchWhen, NgSwitchDefault} from './ng_switch';
|
||||
* one could import all the core directives at once:
|
||||
*
|
||||
* ```typescript
|
||||
* import {CORE_DIRECTIVES} from 'angular2/angular2';
|
||||
* import {CORE_DIRECTIVES} from 'angular2/common';
|
||||
* import {OtherDirective} from './myDirectives';
|
||||
*
|
||||
* @Component({
|
||||
|
@ -31,13 +31,14 @@ import {StringMapWrapper, isListLikeIterable} from 'angular2/src/facade/collecti
|
||||
* ### Example ([live demo](http://plnkr.co/edit/a4YdtmWywhJ33uqfpPPn?p=preview)):
|
||||
*
|
||||
* ```
|
||||
* import {Component, NgClass} from 'angular2/angular2';
|
||||
* import {Component} from 'angular2/core';
|
||||
* import {NgClass} from 'angular2/common';
|
||||
*
|
||||
* @Component({
|
||||
* selector: 'toggle-button',
|
||||
* inputs: ['isDisabled'],
|
||||
* template: `
|
||||
* <div class="button" [ng-class]="{active: isOn, disabled: isDisabled}"
|
||||
* <div class="button" [ngClass]="{active: isOn, disabled: isDisabled}"
|
||||
* (click)="toggle(!isOn)">
|
||||
* Click me!
|
||||
* </div>`,
|
||||
@ -70,7 +71,7 @@ import {StringMapWrapper, isListLikeIterable} from 'angular2/src/facade/collecti
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
@Directive({selector: '[ng-class]', inputs: ['rawClass: ng-class', 'initialClasses: class']})
|
||||
@Directive({selector: '[ngClass]', inputs: ['rawClass: ngClass', 'initialClasses: class']})
|
||||
export class NgClass implements DoCheck, OnDestroy {
|
||||
private _differ: any;
|
||||
private _mode: string;
|
||||
@ -168,10 +169,10 @@ export class NgClass implements DoCheck, OnDestroy {
|
||||
if (className.indexOf(' ') > -1) {
|
||||
var classes = className.split(/\s+/g);
|
||||
for (var i = 0, len = classes.length; i < len; i++) {
|
||||
this._renderer.setElementClass(this._ngEl, classes[i], enabled);
|
||||
this._renderer.setElementClass(this._ngEl.nativeElement, classes[i], enabled);
|
||||
}
|
||||
} else {
|
||||
this._renderer.setElementClass(this._ngEl, className, enabled);
|
||||
this._renderer.setElementClass(this._ngEl.nativeElement, className, enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user