@angular-wave/angular.ts 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (645) hide show
  1. package/@types/index.d.ts +1 -84
  2. package/{src/index.ts → @types/namespace.d.ts} +4 -24
  3. package/@types/router/template-factory.d.ts +2 -2
  4. package/dist/angular-ts.esm.js +3 -3
  5. package/dist/angular-ts.umd.js +3 -3
  6. package/dist/angular-ts.umd.min.js +1 -1
  7. package/package.json +8 -1
  8. package/.github/workflows/ci.yml +0 -104
  9. package/.github/workflows/gh-pages.yml +0 -75
  10. package/.husky/pre-commit +0 -5
  11. package/.prettierignore +0 -9
  12. package/CHANGELOG.md +0 -17667
  13. package/CODE_OF_CONDUCT.md +0 -3
  14. package/CONTRIBUTING.md +0 -247
  15. package/DEVELOPERS.md +0 -499
  16. package/Makefile +0 -60
  17. package/RELEASE.md +0 -86
  18. package/TRIAGING.md +0 -127
  19. package/docs/.cspell.yml +0 -8
  20. package/docs/.github/dependabot.yml +0 -14
  21. package/docs/.nvmrc +0 -1
  22. package/docs/CONTRIBUTING.md +0 -28
  23. package/docs/Dockerfile +0 -4
  24. package/docs/LICENSE +0 -201
  25. package/docs/README.md +0 -217
  26. package/docs/assets/icons/logo.svg +0 -1
  27. package/docs/assets/scss/_variables_project.scss +0 -12
  28. package/docs/assets/scss/_variables_project_after_bs.scss +0 -8
  29. package/docs/assets/scss/index.scss +0 -48
  30. package/docs/config.yaml +0 -15
  31. package/docs/content/_index.md +0 -28
  32. package/docs/content/docs/_index.md +0 -61
  33. package/docs/content/docs/directive/_index.md +0 -4
  34. package/docs/content/docs/directive/app.md +0 -11
  35. package/docs/content/docs/directive/aria.md +0 -0
  36. package/docs/content/docs/directive/bind.md +0 -72
  37. package/docs/content/docs/directive/blur.md +0 -38
  38. package/docs/content/docs/directive/channel.md +0 -37
  39. package/docs/content/docs/directive/class-even.md +0 -47
  40. package/docs/content/docs/directive/class-odd.md +0 -48
  41. package/docs/content/docs/directive/class.md +0 -64
  42. package/docs/content/docs/directive/click.md +0 -41
  43. package/docs/content/docs/directive/cloak.md +0 -74
  44. package/docs/content/docs/directive/copy.md +0 -38
  45. package/docs/content/docs/directive/cut.md +0 -40
  46. package/docs/content/docs/directive/dblclick.md +0 -41
  47. package/docs/content/docs/directive/focus.md +0 -38
  48. package/docs/content/docs/directive/get.md +0 -203
  49. package/docs/content/docs/directive/include.md +0 -7
  50. package/docs/content/docs/directive/keydown.md +0 -38
  51. package/docs/content/docs/directive/keyup.md +0 -38
  52. package/docs/content/docs/directive/load.md +0 -43
  53. package/docs/content/docs/directive/mousedown.md +0 -38
  54. package/docs/content/docs/directive/mouseenter.md +0 -38
  55. package/docs/content/docs/directive/mouseleave.md +0 -38
  56. package/docs/content/docs/directive/mousemove.md +0 -38
  57. package/docs/content/docs/directive/mouseout.md +0 -38
  58. package/docs/content/docs/directive/mouseover.md +0 -38
  59. package/docs/content/docs/directive/mouseup.md +0 -38
  60. package/docs/content/docs/directive/non-bindable.md +0 -28
  61. package/docs/content/docs/filter/_index.md +0 -4
  62. package/docs/content/docs/filter/filter.md +0 -78
  63. package/docs/content/docs/filter/json.md +0 -19
  64. package/docs/content/docs/filter/limit-to.md +0 -30
  65. package/docs/content/docs/filter/order-by.md +0 -123
  66. package/docs/content/docs/provider/_index.md +0 -4
  67. package/docs/content/docs/provider/eventBusProvider.md +0 -35
  68. package/docs/content/docs/provider/locationProvider.md +0 -26
  69. package/docs/content/docs/provider/logProvider.md +0 -59
  70. package/docs/content/docs/provider/sceProvider.md +0 -194
  71. package/docs/content/docs/provider/templateCacheProvider.md +0 -100
  72. package/docs/content/docs/provider/templateRequestProvider.md +0 -5
  73. package/docs/content/docs/service/_index.md +0 -4
  74. package/docs/content/docs/service/compile.md +0 -5
  75. package/docs/content/docs/service/controller.md +0 -5
  76. package/docs/content/docs/service/eventBus.md +0 -56
  77. package/docs/content/docs/service/http.md +0 -161
  78. package/docs/content/docs/service/interpolation.md +0 -5
  79. package/docs/content/docs/service/location.md +0 -57
  80. package/docs/content/docs/service/log.md +0 -113
  81. package/docs/content/docs/service/parse.md +0 -5
  82. package/docs/content/docs/service/rootElement.md +0 -5
  83. package/docs/content/docs/service/rootScope.md +0 -5
  84. package/docs/content/docs/service/sce.md +0 -194
  85. package/docs/content/docs/service/templateCache.md +0 -64
  86. package/docs/content/docs/service/templateRequest.md +0 -5
  87. package/docs/content/docs/service/url.md +0 -5
  88. package/docs/content/docs/values/_index.md +0 -4
  89. package/docs/content/docs/values/document.md +0 -29
  90. package/docs/content/docs/values/window.md +0 -29
  91. package/docs/docker-compose.yaml +0 -12
  92. package/docs/docsy.work +0 -5
  93. package/docs/docsy.work.sum +0 -0
  94. package/docs/go.mod +0 -5
  95. package/docs/go.sum +0 -6
  96. package/docs/hugo-disabled.toml +0 -220
  97. package/docs/hugo.yaml +0 -200
  98. package/docs/layouts/404.html +0 -13
  99. package/docs/layouts/_markup/render-heading.html +0 -1
  100. package/docs/layouts/partials/hooks/head-end.html +0 -3
  101. package/docs/layouts/shortcodes/showcss.html +0 -2
  102. package/docs/layouts/shortcodes/showhtml.html +0 -2
  103. package/docs/layouts/shortcodes/showjs.html +0 -2
  104. package/docs/layouts/shortcodes/showraw.html +0 -1
  105. package/docs/layouts/shortcodes/version.html +0 -1
  106. package/docs/package-lock.json +0 -2293
  107. package/docs/package.json +0 -53
  108. package/docs/static/examples/counter/counter-test.html +0 -13
  109. package/docs/static/examples/counter/counter.html +0 -5
  110. package/docs/static/examples/counter/counter.test.js +0 -28
  111. package/docs/static/examples/document/document.html +0 -3
  112. package/docs/static/examples/eventbus/eventbus-test.html +0 -15
  113. package/docs/static/examples/eventbus/eventbus.html +0 -13
  114. package/docs/static/examples/eventbus/eventbus.js +0 -15
  115. package/docs/static/examples/eventbus/eventbus.test.js +0 -19
  116. package/docs/static/examples/i18n/i18n.html +0 -77
  117. package/docs/static/examples/ng-bind/ng-bind.html +0 -9
  118. package/docs/static/examples/ng-blur/ng-blur.html +0 -9
  119. package/docs/static/examples/ng-channel/ng-channel-test.html +0 -17
  120. package/docs/static/examples/ng-channel/ng-channel.html +0 -24
  121. package/docs/static/examples/ng-channel/ng-channel.test.js +0 -31
  122. package/docs/static/examples/ng-class/ng-class.html +0 -71
  123. package/docs/static/examples/ng-class-even/ng-class-even.html +0 -8
  124. package/docs/static/examples/ng-class-odd/ng-class-odd.html +0 -8
  125. package/docs/static/examples/ng-click/ng-click.html +0 -6
  126. package/docs/static/examples/ng-copy/ng-copy.html +0 -6
  127. package/docs/static/examples/ng-cut/ng-cut.html +0 -6
  128. package/docs/static/examples/ng-dblclick/ng-dblclick.html +0 -10
  129. package/docs/static/examples/ng-focus/ng-focus.html +0 -9
  130. package/docs/static/examples/ng-keydown/ng-keydown.html +0 -9
  131. package/docs/static/examples/ng-keyup/ng-keyup.html +0 -9
  132. package/docs/static/examples/ng-load/ng-load.html +0 -8
  133. package/docs/static/examples/ng-mousedown/ng-mousedown.html +0 -6
  134. package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +0 -4
  135. package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +0 -4
  136. package/docs/static/examples/ng-mousemove/ng-mousemove.html +0 -4
  137. package/docs/static/examples/ng-mouseout/ng-mouseout.html +0 -4
  138. package/docs/static/examples/ng-mouseover/ng-mouseover.html +0 -4
  139. package/docs/static/examples/ng-mouseup/ng-mouseup.html +0 -4
  140. package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +0 -13
  141. package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +0 -3
  142. package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +0 -11
  143. package/docs/static/examples/window/window.html +0 -4
  144. package/docs/static/typedoc/.nojekyll +0 -1
  145. package/docs/static/typedoc/assets/hierarchy.js +0 -1
  146. package/docs/static/typedoc/assets/highlight.css +0 -29
  147. package/docs/static/typedoc/assets/icons.js +0 -18
  148. package/docs/static/typedoc/assets/icons.svg +0 -1
  149. package/docs/static/typedoc/assets/main.js +0 -60
  150. package/docs/static/typedoc/assets/navigation.js +0 -1
  151. package/docs/static/typedoc/assets/search.js +0 -1
  152. package/docs/static/typedoc/assets/style.css +0 -1633
  153. package/docs/static/typedoc/classes/Location.html +0 -55
  154. package/docs/static/typedoc/classes/LocationProvider.html +0 -20
  155. package/docs/static/typedoc/classes/LogProvider.html +0 -6
  156. package/docs/static/typedoc/classes/PubSub.html +0 -71
  157. package/docs/static/typedoc/classes/PubSubProvider.html +0 -4
  158. package/docs/static/typedoc/classes/TemplateCacheProvider.html +0 -5
  159. package/docs/static/typedoc/hierarchy.html +0 -1
  160. package/docs/static/typedoc/index.html +0 -1
  161. package/docs/static/typedoc/interfaces/DefaultPorts.html +0 -5
  162. package/docs/static/typedoc/interfaces/Html5Mode.html +0 -23
  163. package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +0 -1
  164. package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +0 -31
  165. package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +0 -6
  166. package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +0 -1
  167. package/docs/static/typedoc/interfaces/HttpResponse.html +0 -7
  168. package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +0 -1
  169. package/docs/static/typedoc/interfaces/HttpService.html +0 -38
  170. package/docs/static/typedoc/interfaces/LogService.html +0 -12
  171. package/docs/static/typedoc/interfaces/RequestConfig.html +0 -48
  172. package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +0 -38
  173. package/docs/static/typedoc/interfaces/ServiceProvider.html +0 -5
  174. package/docs/static/typedoc/interfaces/UrlParts.html +0 -9
  175. package/docs/static/typedoc/types/HttpParamSerializer.html +0 -2
  176. package/docs/static/typedoc/types/HttpParams.html +0 -2
  177. package/docs/static/typedoc/types/HttpPromise.html +0 -1
  178. package/docs/static/typedoc/types/HttpResponseStatus.html +0 -1
  179. package/docs/static/typedoc/types/LogCall.html +0 -2
  180. package/docs/static/typedoc/types/LogServiceFactory.html +0 -2
  181. package/docs/static/typedoc/types/UrlChangeListener.html +0 -5
  182. package/docs/static/typedoc/variables/EventBus.html +0 -1
  183. package/docs/static/version.js +0 -13
  184. package/docs/test-results/.last-run.json +0 -4
  185. package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +0 -50
  186. package/eslint.config.js +0 -26
  187. package/images/android-chrome-192x192.png +0 -0
  188. package/images/android-chrome-512x512.png +0 -0
  189. package/images/apple-touch-icon.png +0 -0
  190. package/images/favicon-16x16.png +0 -0
  191. package/images/favicon-32x32.png +0 -0
  192. package/images/favicon.ico +0 -0
  193. package/images/site.webmanifest +0 -19
  194. package/index.html +0 -86
  195. package/legacy.d.ts +0 -1678
  196. package/playwright.config.ts +0 -81
  197. package/public/jasmine/boot0.js +0 -66
  198. package/public/jasmine/boot1.js +0 -134
  199. package/public/jasmine/jasmine-html.js +0 -970
  200. package/public/jasmine/jasmine.css +0 -323
  201. package/public/jasmine/jasmine.js +0 -11406
  202. package/public/public/README.md +0 -1
  203. package/public/public/circle.html +0 -1
  204. package/public/public/jasmine-helper.css +0 -9
  205. package/public/public/my_child_directive.html +0 -1
  206. package/public/public/my_directive.html +0 -1
  207. package/public/public/my_other_directive.html +0 -1
  208. package/public/public/test.html +0 -1
  209. package/rollup.config.js +0 -51
  210. package/src/angular.js +0 -286
  211. package/src/angular.spec.js +0 -1191
  212. package/src/animations/animate-cache.js +0 -80
  213. package/src/animations/animate-children-directive.js +0 -32
  214. package/src/animations/animate-children-directive.md +0 -80
  215. package/src/animations/animate-css-driver.js +0 -284
  216. package/src/animations/animate-css.html +0 -58
  217. package/src/animations/animate-css.js +0 -915
  218. package/src/animations/animate-css.md +0 -263
  219. package/src/animations/animate-js-driver.js +0 -60
  220. package/src/animations/animate-js.html +0 -47
  221. package/src/animations/animate-js.js +0 -371
  222. package/src/animations/animate-queue.js +0 -859
  223. package/src/animations/animate-runner.js +0 -193
  224. package/src/animations/animate-swap.js +0 -33
  225. package/src/animations/animate-swap.md +0 -88
  226. package/src/animations/animate.html +0 -19
  227. package/src/animations/animate.js +0 -546
  228. package/src/animations/animate.md +0 -933
  229. package/src/animations/animate.spec.js +0 -490
  230. package/src/animations/animation.js +0 -519
  231. package/src/animations/animations.test.js +0 -10
  232. package/src/animations/interface.ts +0 -19
  233. package/src/animations/raf-scheduler.html +0 -19
  234. package/src/animations/raf-scheduler.js +0 -92
  235. package/src/animations/raf-scheduler.spec.js +0 -98
  236. package/src/animations/shared.js +0 -341
  237. package/src/binding.html +0 -19
  238. package/src/binding.spec.js +0 -474
  239. package/src/binding.test.js +0 -10
  240. package/src/core/compile/attributes.js +0 -337
  241. package/src/core/compile/compile.html +0 -19
  242. package/src/core/compile/compile.js +0 -3271
  243. package/src/core/compile/compile.md +0 -1128
  244. package/src/core/compile/compile.spec.js +0 -15574
  245. package/src/core/compile/compile.test.js +0 -12
  246. package/src/core/controller/controller.html +0 -22
  247. package/src/core/controller/controller.js +0 -193
  248. package/src/core/controller/controller.spec.js +0 -334
  249. package/src/core/controller/controller.test.js +0 -12
  250. package/src/core/controller/interface.ts +0 -6
  251. package/src/core/core.html +0 -20
  252. package/src/core/core.test.js +0 -12
  253. package/src/core/di/injector.html +0 -19
  254. package/src/core/di/injector.js +0 -307
  255. package/src/core/di/injector.md +0 -740
  256. package/src/core/di/injector.spec.js +0 -2310
  257. package/src/core/di/injector.test.js +0 -12
  258. package/src/core/di/internal-injector.js +0 -286
  259. package/src/core/di/ng-module.html +0 -19
  260. package/src/core/di/ng-module.js +0 -229
  261. package/src/core/di/ng-module.spec.js +0 -263
  262. package/src/core/di/ng-module.test.js +0 -12
  263. package/src/core/filter/filter.html +0 -19
  264. package/src/core/filter/filter.js +0 -55
  265. package/src/core/filter/filter.md +0 -132
  266. package/src/core/filter/filter.spec.js +0 -149
  267. package/src/core/filter/filter.test.js +0 -12
  268. package/src/core/interpolate/interface.ts +0 -14
  269. package/src/core/interpolate/interpolate.html +0 -22
  270. package/src/core/interpolate/interpolate.js +0 -410
  271. package/src/core/interpolate/interpolate.spec.js +0 -601
  272. package/src/core/interpolate/interpolate.test.js +0 -12
  273. package/src/core/parse/ast/ast-node.ts +0 -81
  274. package/src/core/parse/ast/ast.html +0 -19
  275. package/src/core/parse/ast/ast.js +0 -574
  276. package/src/core/parse/ast/ast.spec.js +0 -1453
  277. package/src/core/parse/ast/ast.test.js +0 -10
  278. package/src/core/parse/ast-type.js +0 -23
  279. package/src/core/parse/interface.ts +0 -84
  280. package/src/core/parse/interpreter.js +0 -915
  281. package/src/core/parse/lexer/lexer.html +0 -19
  282. package/src/core/parse/lexer/lexer.js +0 -338
  283. package/src/core/parse/lexer/lexer.spec.js +0 -303
  284. package/src/core/parse/lexer/lexer.test.js +0 -10
  285. package/src/core/parse/lexer/token.ts +0 -22
  286. package/src/core/parse/parse.html +0 -19
  287. package/src/core/parse/parse.js +0 -337
  288. package/src/core/parse/parse.md +0 -57
  289. package/src/core/parse/parse.spec.js +0 -2107
  290. package/src/core/parse/parse.test.js +0 -10
  291. package/src/core/parse/parser/parser.html +0 -19
  292. package/src/core/parse/parser/parser.js +0 -64
  293. package/src/core/parse/parser/parser.spec.js +0 -8
  294. package/src/core/parse/parser/parser.test.js +0 -10
  295. package/src/core/prop.spec.js +0 -775
  296. package/src/core/root-element.spec.js +0 -14
  297. package/src/core/sanitize/interface.ts +0 -10
  298. package/src/core/sanitize/sanitize-uri.js +0 -75
  299. package/src/core/sanitize/sanitize-uri.spec.js +0 -249
  300. package/src/core/sanitize/sanitize-uri.test.js +0 -12
  301. package/src/core/sanitize/sanitize.html +0 -22
  302. package/src/core/scope/scope.html +0 -19
  303. package/src/core/scope/scope.js +0 -1252
  304. package/src/core/scope/scope.spec.js +0 -3000
  305. package/src/core/scope/scope.test.js +0 -12
  306. package/src/directive/aria/aria.html +0 -19
  307. package/src/directive/aria/aria.js +0 -382
  308. package/src/directive/aria/aria.md +0 -145
  309. package/src/directive/aria/aria.spec.js +0 -1241
  310. package/src/directive/aria/aria.test.js +0 -12
  311. package/src/directive/attrs/attrs.html +0 -19
  312. package/src/directive/attrs/attrs.js +0 -106
  313. package/src/directive/attrs/attrs.md +0 -224
  314. package/src/directive/attrs/attrs.spec.js +0 -71
  315. package/src/directive/attrs/attrs.test.js +0 -12
  316. package/src/directive/attrs/boolean.html +0 -19
  317. package/src/directive/attrs/boolean.spec.js +0 -137
  318. package/src/directive/attrs/boolean.test.js +0 -12
  319. package/src/directive/attrs/element-style.html +0 -22
  320. package/src/directive/attrs/element-style.spec.js +0 -85
  321. package/src/directive/attrs/element-style.test.js +0 -12
  322. package/src/directive/attrs/src.html +0 -19
  323. package/src/directive/attrs/src.spec.js +0 -163
  324. package/src/directive/attrs/src.test.js +0 -12
  325. package/src/directive/bind/bind-html.spec.js +0 -36
  326. package/src/directive/bind/bind.html +0 -20
  327. package/src/directive/bind/bind.js +0 -78
  328. package/src/directive/bind/bind.md +0 -142
  329. package/src/directive/bind/bind.spec.js +0 -314
  330. package/src/directive/bind/bind.test.js +0 -12
  331. package/src/directive/channel/channel.html +0 -19
  332. package/src/directive/channel/channel.js +0 -30
  333. package/src/directive/channel/channel.spec.js +0 -67
  334. package/src/directive/channel/channel.test.js +0 -10
  335. package/src/directive/class/class-test.html +0 -23
  336. package/src/directive/class/class.html +0 -19
  337. package/src/directive/class/class.js +0 -184
  338. package/src/directive/class/class.spec.js +0 -704
  339. package/src/directive/class/class.test.js +0 -12
  340. package/src/directive/cloak/cloak.html +0 -19
  341. package/src/directive/cloak/cloak.js +0 -11
  342. package/src/directive/cloak/cloak.spec.js +0 -44
  343. package/src/directive/cloak/cloak.test.js +0 -12
  344. package/src/directive/controller/controller.html +0 -22
  345. package/src/directive/controller/controller.js +0 -11
  346. package/src/directive/controller/controller.md +0 -46
  347. package/src/directive/controller/controller.spec.js +0 -175
  348. package/src/directive/controller/controller.test.js +0 -12
  349. package/src/directive/events/click.spec.js +0 -35
  350. package/src/directive/events/event.spec.js +0 -267
  351. package/src/directive/events/events-test.html +0 -36
  352. package/src/directive/events/events.html +0 -20
  353. package/src/directive/events/events.js +0 -65
  354. package/src/directive/events/events.md +0 -125
  355. package/src/directive/events/events.test.js +0 -12
  356. package/src/directive/form/form.html +0 -19
  357. package/src/directive/form/form.js +0 -669
  358. package/src/directive/form/form.spec.js +0 -1515
  359. package/src/directive/form/form.test.js +0 -12
  360. package/src/directive/http/delete.spec.js +0 -23
  361. package/src/directive/http/form-router-test.html +0 -44
  362. package/src/directive/http/form-test.html +0 -18
  363. package/src/directive/http/get.spec.js +0 -488
  364. package/src/directive/http/http.html +0 -22
  365. package/src/directive/http/http.js +0 -342
  366. package/src/directive/http/http.test.js +0 -12
  367. package/src/directive/http/interface.ts +0 -36
  368. package/src/directive/http/post-example.html +0 -30
  369. package/src/directive/http/post.spec.js +0 -521
  370. package/src/directive/http/put.spec.js +0 -23
  371. package/src/directive/if/if-animate-css.html +0 -57
  372. package/src/directive/if/if-animate-svg.html +0 -25
  373. package/src/directive/if/if.html +0 -19
  374. package/src/directive/if/if.js +0 -72
  375. package/src/directive/if/if.md +0 -76
  376. package/src/directive/if/if.spec.js +0 -293
  377. package/src/directive/if/if.test.js +0 -114
  378. package/src/directive/include/include.html +0 -19
  379. package/src/directive/include/include.js +0 -151
  380. package/src/directive/include/include.md +0 -87
  381. package/src/directive/include/include.spec.js +0 -734
  382. package/src/directive/include/include.test.js +0 -12
  383. package/src/directive/init/init.html +0 -19
  384. package/src/directive/init/init.js +0 -22
  385. package/src/directive/init/init.md +0 -41
  386. package/src/directive/init/init.spec.js +0 -68
  387. package/src/directive/init/init.test.js +0 -12
  388. package/src/directive/inject/inject.html +0 -19
  389. package/src/directive/inject/inject.js +0 -35
  390. package/src/directive/inject/inject.spec.js +0 -108
  391. package/src/directive/inject/inject.test.js +0 -12
  392. package/src/directive/input/input-example.html +0 -15
  393. package/src/directive/input/input.html +0 -19
  394. package/src/directive/input/input.js +0 -1078
  395. package/src/directive/input/input.md +0 -706
  396. package/src/directive/input/input.spec.js +0 -3700
  397. package/src/directive/input/input.test.js +0 -12
  398. package/src/directive/messages/messages.html +0 -22
  399. package/src/directive/messages/messages.js +0 -349
  400. package/src/directive/messages/messages.md +0 -543
  401. package/src/directive/messages/messages.spec.js +0 -1083
  402. package/src/directive/messages/messages.test.js +0 -12
  403. package/src/directive/model/change.md +0 -25
  404. package/src/directive/model/model.html +0 -19
  405. package/src/directive/model/model.js +0 -1170
  406. package/src/directive/model/model.spec.js +0 -1976
  407. package/src/directive/model/model.test.js +0 -12
  408. package/src/directive/model-options/model-option.test.js +0 -12
  409. package/src/directive/model-options/model-options.html +0 -22
  410. package/src/directive/model-options/model-options.js +0 -142
  411. package/src/directive/model-options/model-options.md +0 -407
  412. package/src/directive/model-options/model-options.spec.js +0 -1022
  413. package/src/directive/non-bindable/non-bindable.html +0 -22
  414. package/src/directive/non-bindable/non-bindable.js +0 -9
  415. package/src/directive/non-bindable/non-bindable.spec.js +0 -59
  416. package/src/directive/non-bindable/non-bindable.test.js +0 -12
  417. package/src/directive/observe/observe-demo.html +0 -184
  418. package/src/directive/observe/observe.html +0 -19
  419. package/src/directive/observe/observe.js +0 -41
  420. package/src/directive/observe/observe.spec.js +0 -106
  421. package/src/directive/observe/observe.test.js +0 -10
  422. package/src/directive/on/on.html +0 -19
  423. package/src/directive/on/on.spec.js +0 -215
  424. package/src/directive/on/on.test.js +0 -12
  425. package/src/directive/options/options-example.html +0 -17
  426. package/src/directive/options/options.html +0 -22
  427. package/src/directive/options/options.js +0 -542
  428. package/src/directive/options/options.md +0 -179
  429. package/src/directive/options/options.spec.js +0 -3554
  430. package/src/directive/options/options.test.js +0 -12
  431. package/src/directive/ref/href.html +0 -19
  432. package/src/directive/ref/href.spec.js +0 -141
  433. package/src/directive/ref/href.test.js +0 -19
  434. package/src/directive/ref/ref.html +0 -19
  435. package/src/directive/ref/ref.js +0 -89
  436. package/src/directive/ref/ref.spec.js +0 -546
  437. package/src/directive/repeat/repeat.html +0 -19
  438. package/src/directive/repeat/repeat.js +0 -333
  439. package/src/directive/repeat/repeat.md +0 -330
  440. package/src/directive/repeat/repeat.spec.js +0 -1209
  441. package/src/directive/repeat/repeat.test.js +0 -12
  442. package/src/directive/script/script.html +0 -19
  443. package/src/directive/script/script.js +0 -17
  444. package/src/directive/script/script.md +0 -11
  445. package/src/directive/script/script.spec.js +0 -47
  446. package/src/directive/script/script.test.js +0 -12
  447. package/src/directive/select/select.html +0 -19
  448. package/src/directive/select/select.js +0 -594
  449. package/src/directive/select/select.md +0 -74
  450. package/src/directive/select/select.spec.js +0 -2566
  451. package/src/directive/select/select.test.js +0 -12
  452. package/src/directive/setter/setter.html +0 -19
  453. package/src/directive/setter/setter.js +0 -59
  454. package/src/directive/setter/setter.spec.js +0 -100
  455. package/src/directive/setter/setter.test.js +0 -12
  456. package/src/directive/show-hide/show-hide.html +0 -22
  457. package/src/directive/show-hide/show-hide.js +0 -65
  458. package/src/directive/show-hide/show-hide.md +0 -255
  459. package/src/directive/show-hide/show-hide.spec.js +0 -268
  460. package/src/directive/show-hide/show-hide.test.js +0 -12
  461. package/src/directive/style/style.html +0 -19
  462. package/src/directive/style/style.js +0 -27
  463. package/src/directive/style/style.md +0 -23
  464. package/src/directive/style/style.spec.js +0 -183
  465. package/src/directive/style/style.test.js +0 -12
  466. package/src/directive/switch/switch.html +0 -19
  467. package/src/directive/switch/switch.js +0 -133
  468. package/src/directive/switch/switch.md +0 -66
  469. package/src/directive/switch/switch.spec.js +0 -509
  470. package/src/directive/switch/switch.test.js +0 -12
  471. package/src/directive/transclude/transclude.js +0 -122
  472. package/src/directive/validators/validators.html +0 -22
  473. package/src/directive/validators/validators.js +0 -346
  474. package/src/directive/validators/validators.spec.js +0 -740
  475. package/src/directive/validators/validators.test.js +0 -12
  476. package/src/filters/filter.js +0 -213
  477. package/src/filters/filter.spec.js +0 -719
  478. package/src/filters/filters.html +0 -22
  479. package/src/filters/filters.js +0 -239
  480. package/src/filters/filters.spec.js +0 -36
  481. package/src/filters/filters.test.js +0 -12
  482. package/src/filters/interface.ts +0 -9
  483. package/src/filters/limit-to.js +0 -55
  484. package/src/filters/limit-to.spec.js +0 -252
  485. package/src/filters/order-by.js +0 -181
  486. package/src/filters/order-by.spec.js +0 -883
  487. package/src/index.js +0 -6
  488. package/src/index.spec.js +0 -11
  489. package/src/injection-tokens.js +0 -81
  490. package/src/interface.ts +0 -430
  491. package/src/ng.js +0 -291
  492. package/src/ng.spec.js +0 -45
  493. package/src/router/common/trace.js +0 -240
  494. package/src/router/directives/component-example.html +0 -37
  495. package/src/router/directives/state-directives.html +0 -22
  496. package/src/router/directives/state-directives.js +0 -393
  497. package/src/router/directives/state-directives.md +0 -435
  498. package/src/router/directives/state-directives.spec.js +0 -1091
  499. package/src/router/directives/state-directives.test.js +0 -10
  500. package/src/router/directives/view-directive.js +0 -489
  501. package/src/router/directives/view-directive.spec.js +0 -1921
  502. package/src/router/directives/view-directive.test.js +0 -10
  503. package/src/router/directives/view-directives.html +0 -22
  504. package/src/router/glob/glob.html +0 -19
  505. package/src/router/glob/glob.js +0 -102
  506. package/src/router/glob/glob.spec.js +0 -108
  507. package/src/router/glob/glob.test.js +0 -12
  508. package/src/router/hooks/core-resolvables.js +0 -38
  509. package/src/router/hooks/ignored-transition.js +0 -25
  510. package/src/router/hooks/invalid-transition.js +0 -14
  511. package/src/router/hooks/lazy-load.js +0 -104
  512. package/src/router/hooks/on-enter-exit-retain.js +0 -55
  513. package/src/router/hooks/redirect-to.js +0 -38
  514. package/src/router/hooks/resolve.js +0 -57
  515. package/src/router/hooks/update-globals.js +0 -34
  516. package/src/router/hooks/url.js +0 -34
  517. package/src/router/hooks/views.js +0 -41
  518. package/src/router/params/interface.ts +0 -626
  519. package/src/router/params/param-factory.js +0 -23
  520. package/src/router/params/param-type.js +0 -133
  521. package/src/router/params/param-types.js +0 -153
  522. package/src/router/params/param.js +0 -243
  523. package/src/router/params/state-params.js +0 -36
  524. package/src/router/path/path-node.js +0 -78
  525. package/src/router/path/path-utils.js +0 -207
  526. package/src/router/resolve/interface.ts +0 -208
  527. package/src/router/resolve/resolvable.js +0 -123
  528. package/src/router/resolve/resolve-context.js +0 -190
  529. package/src/router/router-test-hashbang.html +0 -45
  530. package/src/router/router-test.html +0 -41
  531. package/src/router/router.html +0 -22
  532. package/src/router/router.js +0 -54
  533. package/src/router/router.test.js +0 -12
  534. package/src/router/services.spec.js +0 -52
  535. package/src/router/state/interface.ts +0 -1007
  536. package/src/router/state/state-builder.js +0 -376
  537. package/src/router/state/state-builder.spec.js +0 -86
  538. package/src/router/state/state-matcher.js +0 -64
  539. package/src/router/state/state-object.js +0 -118
  540. package/src/router/state/state-queue-manager.js +0 -95
  541. package/src/router/state/state-registry.js +0 -262
  542. package/src/router/state/state-service.js +0 -687
  543. package/src/router/state/state.html +0 -23
  544. package/src/router/state/state.spec.js +0 -1002
  545. package/src/router/state/state.test.js +0 -12
  546. package/src/router/state/target-state.js +0 -162
  547. package/src/router/state/views.js +0 -195
  548. package/src/router/state-filter.spec.js +0 -139
  549. package/src/router/state-filters.js +0 -46
  550. package/src/router/template-factory.html +0 -19
  551. package/src/router/template-factory.js +0 -249
  552. package/src/router/template-factory.spec.js +0 -146
  553. package/src/router/template-factory.test.js +0 -12
  554. package/src/router/transition/hook-builder.js +0 -137
  555. package/src/router/transition/hook-registry.js +0 -181
  556. package/src/router/transition/interface.js +0 -18
  557. package/src/router/transition/interface.ts +0 -922
  558. package/src/router/transition/reject-factory.js +0 -122
  559. package/src/router/transition/transition-event-type.js +0 -26
  560. package/src/router/transition/transition-hook.js +0 -199
  561. package/src/router/transition/transition-service.js +0 -297
  562. package/src/router/transition/transition.js +0 -653
  563. package/src/router/url/url-config.js +0 -155
  564. package/src/router/url/url-matcher.js +0 -532
  565. package/src/router/url/url-rule.js +0 -231
  566. package/src/router/url/url-rules.js +0 -350
  567. package/src/router/url/url-service.js +0 -446
  568. package/src/router/url/url-service.spec.js +0 -1288
  569. package/src/router/url/url.html +0 -19
  570. package/src/router/url/url.test.js +0 -12
  571. package/src/router/view/interface.ts +0 -51
  572. package/src/router/view/view.html +0 -19
  573. package/src/router/view/view.js +0 -262
  574. package/src/router/view/view.spec.js +0 -100
  575. package/src/router/view/view.test.js +0 -12
  576. package/src/router/view-hook.spec.js +0 -215
  577. package/src/router/view-scroll.js +0 -33
  578. package/src/router/view-scroll.spec.js +0 -72
  579. package/src/services/anchor-scroll/anchor-scroll.html +0 -76
  580. package/src/services/anchor-scroll/anchor-scroll.js +0 -147
  581. package/src/services/exception/exception-handler.js +0 -75
  582. package/src/services/exception/interface.ts +0 -7
  583. package/src/services/http/http.html +0 -23
  584. package/src/services/http/http.js +0 -1109
  585. package/src/services/http/http.spec.js +0 -4320
  586. package/src/services/http/http.test.js +0 -11
  587. package/src/services/http/interface.ts +0 -256
  588. package/src/services/http/template-request.spec.js +0 -220
  589. package/src/services/location/interface.ts +0 -70
  590. package/src/services/location/location.html +0 -22
  591. package/src/services/location/location.js +0 -1006
  592. package/src/services/location/location.spec.js +0 -3792
  593. package/src/services/location/location.test.js +0 -12
  594. package/src/services/log/interface.ts +0 -39
  595. package/src/services/log/log.html +0 -19
  596. package/src/services/log/log.js +0 -74
  597. package/src/services/log/log.spec.js +0 -64
  598. package/src/services/log/log.test.js +0 -12
  599. package/src/services/pubsub/pubsub.html +0 -19
  600. package/src/services/pubsub/pubsub.js +0 -349
  601. package/src/services/pubsub/pubsub.spec.js +0 -400
  602. package/src/services/pubsub/pubsub.test.js +0 -12
  603. package/src/services/sce/sce.html +0 -19
  604. package/src/services/sce/sce.js +0 -852
  605. package/src/services/sce/sce.spec.js +0 -617
  606. package/src/services/sce/sce.test.js +0 -12
  607. package/src/services/template-cache/template-cache.html +0 -22
  608. package/src/services/template-cache/template-cache.js +0 -15
  609. package/src/services/template-cache/template-cache.spec.js +0 -134
  610. package/src/services/template-cache/template-cache.test.js +0 -12
  611. package/src/services/template-request/interface.ts +0 -23
  612. package/src/services/template-request/template-request.js +0 -142
  613. package/src/shared/cache.js +0 -7
  614. package/src/shared/common.js +0 -365
  615. package/src/shared/common.spec.js +0 -294
  616. package/src/shared/constants.js +0 -21
  617. package/src/shared/dom.js +0 -716
  618. package/src/shared/hof.js +0 -157
  619. package/src/shared/hof.spec.js +0 -60
  620. package/src/shared/interface.ts +0 -21
  621. package/src/shared/min-err.spec.js +0 -178
  622. package/src/shared/noderef.js +0 -225
  623. package/src/shared/predicates.js +0 -34
  624. package/src/shared/queue.js +0 -105
  625. package/src/shared/queue.spec.js +0 -80
  626. package/src/shared/shared.html +0 -24
  627. package/src/shared/shared.test.js +0 -12
  628. package/src/shared/strings.js +0 -142
  629. package/src/shared/strings.spec.js +0 -40
  630. package/src/shared/test-utils.js +0 -47
  631. package/src/shared/url-utils/interface.ts +0 -54
  632. package/src/shared/url-utils/url-utils.html +0 -22
  633. package/src/shared/url-utils/url-utils.js +0 -122
  634. package/src/shared/url-utils/url-utils.spec.js +0 -148
  635. package/src/shared/url-utils/url-utils.test.js +0 -12
  636. package/src/shared/utils.js +0 -1255
  637. package/src/shared/utils.spec.js +0 -178
  638. package/src/src.html +0 -21
  639. package/src/src.test.js +0 -10
  640. package/tsconfig.json +0 -19
  641. package/tsconfig.types.json +0 -14
  642. package/typedoc.json +0 -8
  643. package/utils/express.js +0 -203
  644. package/utils/version.cjs +0 -23
  645. package/vite.config.js +0 -14
@@ -1,1921 +0,0 @@
1
- import { createElementFromHTML, dealoc } from "../../shared/dom.js";
2
- import { Angular } from "../../angular.js";
3
- import { wait } from "../../shared/test-utils.js";
4
-
5
- describe("ngView", () => {
6
- window.location.hash = "";
7
- let $stateProvider,
8
- scope,
9
- $compile,
10
- elem = document.getElementById("app"),
11
- log,
12
- app,
13
- $injector,
14
- $state,
15
- $viewScroll;
16
-
17
- const aState = {
18
- name: "a",
19
- template: "aState template",
20
- },
21
- bState = {
22
- name: "b",
23
- template: "bState template",
24
- },
25
- cState = {
26
- name: "c",
27
- views: {
28
- cview: {
29
- template: "cState cview template",
30
- },
31
- },
32
- },
33
- dState = {
34
- name: "d",
35
- views: {
36
- dview1: {
37
- template: "dState dview1 template",
38
- },
39
- dview2: {
40
- template: "dState dview2 template",
41
- },
42
- },
43
- },
44
- eState = {
45
- name: "e",
46
- template: '<div ng-view="eview" class="eview"></div>',
47
- },
48
- fState = {
49
- name: "e.f",
50
- views: {
51
- eview: {
52
- template: "fState eview template",
53
- },
54
- },
55
- },
56
- gState = {
57
- name: "g",
58
- template: '<div ng-view="inner"><span>{{content}}</span></div>',
59
- },
60
- hState = {
61
- name: "g.h",
62
- views: {
63
- inner: {
64
- template: "hState inner template",
65
- },
66
- },
67
- },
68
- iState = {
69
- name: "i",
70
- template:
71
- "<div ng-view>" +
72
- '<ul><li ng-repeat="item in items">{{item}}</li></ul>' +
73
- "</div>",
74
- },
75
- jState = {
76
- name: "j",
77
- template: "jState",
78
- },
79
- kState = {
80
- name: "k",
81
- controller: function () {
82
- this.someProperty = "value";
83
- },
84
- template: "{{vm.someProperty}}",
85
- controllerAs: "vm",
86
- },
87
- lState = {
88
- name: "l",
89
- views: {
90
- view1: {
91
- template: "view1",
92
- },
93
- view2: {
94
- template: "view2",
95
- },
96
- view3: {
97
- template: "view3",
98
- },
99
- },
100
- },
101
- mState = {
102
- name: "m",
103
- template: "mState",
104
- controller: function ($scope, $element) {
105
- $scope.elementId = $element.getAttribute("id");
106
- },
107
- },
108
- nState = {
109
- name: "n",
110
- template: "nState",
111
- controller: function ($scope, $element) {
112
- const data = getCacheData($element, "$ngViewAnim");
113
- $scope.$on("$destroy", () => {
114
- log += "destroy;";
115
- });
116
- data.$animEnter.then(() => {
117
- log += "animEnter;";
118
- });
119
- data.$animLeave.then(() => {
120
- log += "animLeave;";
121
- });
122
- },
123
- };
124
-
125
- beforeEach(() => {
126
- dealoc(document.getElementById("app"));
127
- window.angular = new Angular();
128
- log = "";
129
- app = window.angular
130
- .module("defaultModule", [])
131
- .config(($provide, _$stateProvider_) => {
132
- $provide.decorator("$viewScroll", () => {
133
- return jasmine.createSpy("$viewScroll");
134
- });
135
-
136
- _$stateProvider_
137
- .state(aState)
138
- .state(bState)
139
- .state(cState)
140
- .state(dState)
141
- .state(eState)
142
- .state(fState)
143
- .state(gState)
144
- .state(hState)
145
- .state(iState)
146
- .state(jState)
147
- .state(kState)
148
- .state(lState)
149
- .state(mState)
150
- .state(nState);
151
-
152
- $stateProvider = _$stateProvider_;
153
- });
154
-
155
- $injector = window.angular.bootstrap(document.getElementById("app"), [
156
- "defaultModule",
157
- ]);
158
-
159
- $injector.invoke((_$state_, $rootScope, _$compile_, _$viewScroll_) => {
160
- scope = $rootScope.$new();
161
- $compile = _$compile_;
162
- $state = _$state_;
163
- $viewScroll = _$viewScroll_;
164
- });
165
- });
166
-
167
- describe("linking ng-directive", () => {
168
- it("anonymous ng-view should be replaced with the template of the current $state", async () => {
169
- elem.innerHTML = "<div><ng-view></ng-view></div>";
170
- $compile(elem)(scope);
171
-
172
- expect(elem.querySelector("ng-view").textContent).toBe("");
173
-
174
- $state.transitionTo(aState);
175
- await wait(100);
176
-
177
- expect(elem.querySelector("ng-view").textContent).toBe(aState.template);
178
- });
179
-
180
- it("named ng-view should be replaced with the template of the current $state", async () => {
181
- elem.innerHTML = '<div><ng-view name="cview"></ng-view></div>';
182
- $compile(elem)(scope);
183
-
184
- $state.transitionTo(cState);
185
- await wait(100);
186
-
187
- expect(elem.querySelector("ng-view").textContent).toBe(
188
- cState.views.cview.template,
189
- );
190
- });
191
-
192
- it("ng-view should be updated after transition to another state", async () => {
193
- elem.innerHTML = "<div><ng-view></ng-view></div>";
194
- $compile(elem)(scope);
195
- expect(elem.querySelector("ng-view").textContent).toBe("");
196
-
197
- $state.transitionTo(aState);
198
- await wait(100);
199
-
200
- expect(elem.querySelector("ng-view").textContent).toBe(aState.template);
201
-
202
- $state.transitionTo(bState);
203
- await wait(100);
204
-
205
- expect(elem.querySelector("ng-view").textContent).toBe(bState.template);
206
- });
207
-
208
- it("should handle NOT nested ng-views", async () => {
209
- elem.innerHTML =
210
- '<div><ng-view name="dview1" class="dview1"></ng-view><ng-view name="dview2" class="dview2"></ng-view></div>';
211
- $compile(elem)(scope);
212
- expect(elem.querySelectorAll("ng-view")[0].textContent).toBe("");
213
- expect(elem.querySelectorAll("ng-view")[1].textContent).toBe("");
214
-
215
- $state.transitionTo(dState);
216
- await wait(100);
217
-
218
- expect(elem.querySelectorAll("ng-view")[0].textContent).toBe(
219
- dState.views.dview1.template,
220
- );
221
- expect(elem.querySelectorAll("ng-view")[1].textContent).toBe(
222
- dState.views.dview2.template,
223
- );
224
- });
225
-
226
- it("should handle nested ng-views (testing two levels deep)", async () => {
227
- elem.innerHTML = "<div><ng-view></ng-view></div>";
228
- $compile(elem)(scope);
229
- expect(elem.querySelector("ng-view").textContent).toBe("");
230
-
231
- $state.transitionTo(fState);
232
- await wait(100);
233
-
234
- expect(elem.querySelector("ng-view").textContent).toBe(
235
- fState.views.eview.template,
236
- );
237
- });
238
- });
239
-
240
- describe("handling initial view", () => {
241
- it("initial view should be compiled if the view is empty", async () => {
242
- const content = "inner content";
243
- scope.content = content;
244
- elem.innerHTML = "<div><ng-view></ng-view></div>";
245
- $compile(elem)(scope);
246
-
247
- $state.transitionTo(gState);
248
- await wait(100);
249
-
250
- expect(elem.querySelector("ng-view").textContent).toBe(content);
251
- });
252
-
253
- it("initial view should be put back after removal of the view", async () => {
254
- const content = "inner content";
255
- scope.content = content;
256
- elem.innerHTML = "<div><ng-view></ng-view></div>";
257
- $compile(elem)(scope);
258
-
259
- $state.go(hState);
260
- await wait(100);
261
-
262
- expect(elem.querySelector("ng-view").textContent).toBe(
263
- hState.views.inner.template,
264
- );
265
-
266
- // going to the parent state which makes the inner view empty
267
- $state.go(gState);
268
- await wait(100);
269
-
270
- expect(elem.querySelector("ng-view").textContent).toBe(content);
271
- });
272
-
273
- // related to issue #435
274
- it("initial view should be transcluded once to prevent breaking other directives", async () => {
275
- scope.items = ["I", "am", "a", "list", "of", "items"];
276
- elem.innerHTML = "<div><ng-view></ng-view></div>";
277
- $compile(elem)(scope);
278
- await wait();
279
- // transition to state that has an initial view
280
- $state.transitionTo(iState);
281
- await wait(100);
282
-
283
- // verify if ng-repeat has been compiled
284
- expect(elem.querySelectorAll("li").length).toBe(scope.items.length);
285
-
286
- // transition to another state that replace the initial content
287
- $state.transitionTo(jState);
288
- await wait(100);
289
- expect(elem.querySelector("ng-view").innerText).toBe(jState.template);
290
-
291
- // transition back to the state with empty subview and the initial view
292
- $state.transitionTo(iState);
293
- await wait(100);
294
-
295
- // verify if the initial view is correct
296
- expect(elem.querySelectorAll("li").length).toBe(scope.items.length);
297
-
298
- // change scope properties
299
- scope.$apply(() => {
300
- scope.items.push(".", "Working?");
301
- });
302
- await wait();
303
- // verify if the initial view has been updated
304
- expect(elem.querySelectorAll("li").length).toBe(scope.items.length);
305
- });
306
- });
307
-
308
- describe("autoscroll attribute", () => {
309
- it("should NOT autoscroll when unspecified", async () => {
310
- elem.innerHTML = "<div><ng-view></ng-view></div>";
311
- $compile(elem)(scope);
312
-
313
- $state.transitionTo(aState);
314
- await wait(100);
315
- expect($viewScroll).not.toHaveBeenCalled();
316
- });
317
-
318
- it("should autoscroll when expression is missing", async () => {
319
- elem.innerHTML = "<div><ng-view autoscroll></ng-view></div>";
320
- $compile(elem)(scope);
321
-
322
- await $state.transitionTo(aState);
323
- await wait(20);
324
-
325
- // animateFlush($animate);
326
-
327
- expect($viewScroll).toHaveBeenCalledWith(elem.querySelector("ng-view"));
328
- });
329
-
330
- it("should autoscroll based on expression", async () => {
331
- scope.doScroll = false;
332
-
333
- elem.innerHTML = "<div><ng-view autoscroll='doScroll'></ng-view></div>";
334
- $compile(elem)(scope);
335
-
336
- $state.transitionTo(aState);
337
- await wait(100);
338
-
339
- expect($viewScroll).not.toHaveBeenCalled();
340
-
341
- scope.doScroll = true;
342
- $state.transitionTo(bState);
343
- await wait(100);
344
- expect($viewScroll).toHaveBeenCalledWith(elem.querySelector("ng-view"));
345
- });
346
- });
347
-
348
- it("should instantiate a controller with controllerAs", async () => {
349
- elem.innerHTML = "<div><ng-view></ng-view></div>";
350
- $compile(elem)(scope);
351
- $state.transitionTo(kState);
352
- await wait(100);
353
- expect(elem.textContent).toBe("value");
354
- });
355
-
356
- it("should instantiate a controller with both $scope and $element injections", async () => {
357
- elem.innerHTML = '<div><ng-view id="mState">{{elementId}}</ng-view></div>';
358
- $compile(elem)(scope);
359
- $state.transitionTo(mState);
360
- await wait(100);
361
-
362
- expect(elem.textContent).toBe("mState");
363
- });
364
-
365
- describe("(resolved data)", () => {
366
- let _scope;
367
- function controller($scope) {
368
- _scope = $scope;
369
- }
370
- let _state;
371
- beforeEach(() => {
372
- _state = {
373
- name: "resolve",
374
- resolve: {
375
- user: function () {
376
- return wait(100).then(() => {
377
- return "joeschmoe";
378
- });
379
- },
380
- },
381
- };
382
- });
383
-
384
- it("should put the resolved data on the controllerAs", async () => {
385
- const state = Object.assign(_state, {
386
- template: "{{$ctrl.$resolve.user}}",
387
- controllerAs: "$ctrl",
388
- controller: function ($scope) {
389
- _scope = $scope;
390
- },
391
- });
392
- $stateProvider.state(state);
393
- elem.innerHTML = "<div><ng-view></ng-view></div>";
394
- $compile(elem)(scope);
395
-
396
- await $state.transitionTo("resolve");
397
- await wait(100);
398
-
399
- expect(elem.textContent).toBe("joeschmoe");
400
- expect(_scope.$resolve).toBeDefined();
401
- expect(_scope.$ctrl).toBeDefined();
402
- expect(_scope.$ctrl.$resolve).toBeDefined();
403
- expect(_scope.$ctrl.$resolve.user).toBe("joeschmoe");
404
- });
405
-
406
- it("should provide the resolved data on the $scope", async () => {
407
- const state = Object.assign(_state, {
408
- template: "{{$resolve.user}}",
409
- controller: controller,
410
- });
411
-
412
- $stateProvider.state(state);
413
- elem.innerHTML = "<div><ng-view></ng-view></div>";
414
- $compile(elem)(scope);
415
-
416
- await $state.transitionTo("resolve");
417
- await wait(100);
418
-
419
- expect(elem.textContent).toBe("joeschmoe");
420
- expect(_scope.$resolve).toBeDefined();
421
- expect(_scope.$resolve.user).toBe("joeschmoe");
422
- });
423
-
424
- // Test for #2626
425
- it("should provide the resolved data on the $scope even if there is no controller", async () => {
426
- const state = Object.assign(_state, {
427
- template: "{{$resolve.user}}",
428
- });
429
- $stateProvider.state(state);
430
- elem.innerHTML = "<div><ng-view></ng-view></div>";
431
- $compile(elem)(scope);
432
- expect(elem.textContent).toBe("");
433
-
434
- await $state.transitionTo("resolve");
435
- await wait(100);
436
-
437
- expect(elem.textContent).toBe("joeschmoe");
438
- });
439
-
440
- it("should put the resolved data on the resolveAs variable", async () => {
441
- const state = Object.assign(_state, {
442
- template: "{{$$$resolve.user}}",
443
- resolveAs: "$$$resolve",
444
- controller: controller,
445
- });
446
- $stateProvider.state(state);
447
- elem.innerHTML = "<div><ng-view></ng-view></div>";
448
- $compile(elem)(scope);
449
-
450
- await $state.transitionTo("resolve");
451
- await wait(100);
452
-
453
- expect(elem.textContent).toBe("joeschmoe");
454
- expect(_scope.$$$resolve).toBeDefined();
455
- expect(_scope.$$$resolve.user).toBe("joeschmoe");
456
- });
457
-
458
- it("should not allow both view-level resolveAs and state-level resolveAs on the same state", async () => {
459
- const views = {
460
- $default: {
461
- controller: controller,
462
- template: "{{$$$resolve.user}}",
463
- resolveAs: "$$$resolve",
464
- },
465
- };
466
- const state = Object.assign(_state, {
467
- resolveAs: "foo",
468
- views: views,
469
- });
470
- expect(() => $stateProvider.state(state)).toThrowError(/resolveAs/);
471
- });
472
- });
473
-
474
- it("should call the existing $onInit after instantiating a controller", async () => {
475
- const $onInit = jasmine.createSpy();
476
- $stateProvider.state({
477
- name: "onInit",
478
- controller: function () {
479
- this.$onInit = $onInit;
480
- },
481
- template: "hi",
482
- controllerAs: "vm",
483
- });
484
- elem.innerHTML = "<div><ng-view></ng-view></div>";
485
- $compile(elem)(scope);
486
- await $state.transitionTo("onInit");
487
- await wait(100);
488
-
489
- expect($onInit).toHaveBeenCalled();
490
- });
491
-
492
- it("should default the template to a '<ng-view>'", async () => {
493
- $stateProvider.state({ name: "abstract", abstract: true });
494
- $stateProvider.state({ name: "abstract.foo", template: "hello" });
495
- elem.innerHTML = "<div><ng-view></ng-view></div>";
496
- $compile(elem)(scope);
497
- $state.transitionTo("abstract.foo");
498
- await wait(100);
499
-
500
- expect(elem.textContent).toBe("hello");
501
- });
502
-
503
- describe("play nicely with other directives", () => {
504
- // related to issue #857
505
- xit("should work with ngIf", async () => {
506
- scope.someBoolean = false;
507
- elem.innerHTML = '<div ng-if="someBoolean"><ng-view></ng-view></div>';
508
- $compile(elem)(scope);
509
- $state.transitionTo(aState);
510
- await wait(100);
511
- // Verify there is no ng-view in the DOM
512
- expect(elem.querySelectorAll("ng-view").length).toBe(0);
513
-
514
- // Turn on the div that holds the ng-view
515
- scope.someBoolean = true;
516
- await wait();
517
- // Verify that the ng-view is there and it has the correct content
518
- expect(elem.querySelector("ng-view").textContent).toBe(aState.template);
519
-
520
- // Turn off the ng-view
521
- scope.someBoolean = false;
522
- await wait();
523
- // Verify there is no ng-view in the DOM
524
- expect(elem.querySelectorAll("ng-view").length).toBe(0);
525
-
526
- // Turn on the div that holds the ng-view once again
527
- scope.someBoolean = true;
528
- await wait();
529
- // Verify that the ng-view is there and it has the correct content
530
- expect(elem.querySelector("ng-view").textContent).toBe(aState.template);
531
- });
532
-
533
- it("should work with ngClass", async () => {
534
- scope.showClass = false;
535
- elem.innerHTML =
536
- "<div><ng-view ng-class=\"{'someClass': showClass}\"></ng-view></div>";
537
- $compile(elem)(scope);
538
- await wait();
539
- expect(elem.querySelector("ng-view").classList).not.toContain(
540
- "someClass",
541
- );
542
-
543
- scope.showClass = true;
544
- await wait();
545
- expect(elem.querySelector("ng-view").classList).toContain("someClass");
546
-
547
- scope.showClass = false;
548
- await wait();
549
- expect(elem.querySelector("ng-view").classList).not.toContain(
550
- "someClass",
551
- );
552
- });
553
-
554
- describe("working with ngRepeat", () => {
555
- xit("should have correct number of ngViews", async () => {
556
- elem.innerHTML =
557
- '<div><ng-view ng-repeat="view in views" name="{{view}}"></ng-view></div>';
558
- $compile(elem)(scope);
559
- await wait();
560
- // Should be no ng-views in DOM
561
- expect(elem.querySelectorAll("ng-view").length).toBe(0);
562
-
563
- // Lets add 3
564
- scope.views = ["view1", "view2", "view3"];
565
- await wait();
566
- // Should be 3 ng-views in the DOM
567
- expect(elem.querySelectorAll("ng-view").length).toBe(
568
- scope.views.length,
569
- );
570
-
571
- // Lets add one more - yay two-way binding
572
- scope.views.push("view4");
573
- await wait();
574
- // Should have 4 ng-views
575
-
576
- expect(elem.querySelectorAll("ng-view").length).toBe(
577
- scope.views.length,
578
- );
579
-
580
- // Lets remove 2 ng-views from the DOM
581
- scope.views.pop();
582
- scope.views.pop();
583
- await wait();
584
- // Should have 2 ng-views
585
- expect(elem.querySelectorAll("ng-view").length).toBe(
586
- scope.views.length,
587
- );
588
- });
589
-
590
- xit("should populate each view with content", async () => {
591
- elem.innerHTML =
592
- '<div><ng-view ng-repeat="view in views" name="{{view}}">defaultcontent</ng-view></div>';
593
- $compile(elem)(scope);
594
- $state.transitionTo(lState);
595
- await wait(100);
596
-
597
- expect(elem.querySelectorAll("ng-view").length).toBe(0);
598
-
599
- scope.views = ["view1", "view2"];
600
-
601
- let ngViews = elem.querySelectorAll("ng-view");
602
-
603
- expect(ngViews[0].textContent).toBe(lState.views.view1.template);
604
- expect(ngViews[1].textContent).toBe(lState.views.view2.template);
605
- expect(ngViews[2].length).toBe(0);
606
-
607
- scope.views.push("view3");
608
- ngViews = elem.querySelector("ng-view");
609
-
610
- expect(ngViews[0].textContent).toBe(lState.views.view1.template);
611
- expect(ngViews[1].textContent).toBe(lState.views.view2.template);
612
- expect(ngViews[2].textContent).toBe(lState.views.view3.template);
613
- });
614
-
615
- xit("should interpolate ng-view names", async () => {
616
- elem.innerHTML =
617
- '<div ng-repeat="view in views">' +
618
- '<ng-view name="view{{$index + 1}}">hallo</ng-view>' +
619
- "</div>";
620
- $compile(elem)(scope);
621
-
622
- await wait(100);
623
- $state.transitionTo(lState);
624
- await wait(100);
625
-
626
- expect(elem.querySelectorAll("ng-view").length).toBe(0);
627
-
628
- scope.views = ["view1", "view2"];
629
- await wait(100);
630
- let ngViews = elem.querySelectorAll("ng-view");
631
-
632
- expect(ngViews[0].textContent).toBe(lState.views.view1.template);
633
- expect(ngViews[1].textContent).toBe(lState.views.view2.template);
634
- //expect(ngViews[2].length).toBe(0);
635
-
636
- scope.views.push("view3");
637
- await wait(100);
638
- ngViews = elem.querySelectorAll("ng-view");
639
-
640
- expect(ngViews[0].textContent).toBe(lState.views.view1.template);
641
- expect(ngViews[1].textContent).toBe(lState.views.view2.template);
642
- expect(ngViews[2].textContent).toBe(lState.views.view3.template);
643
- });
644
- });
645
- });
646
-
647
- // describe("AngularTS Animations", () => {
648
- // it("should do transition animations", async () => {
649
- // let content = "Initial Content",
650
- // animation;
651
- // elem.append(
652
- // $compile("<div><ng-view>" + content + "</ng-view></div>")(scope),
653
- // );
654
-
655
- // // Enter Animation
656
- // animation = $animate.queue.shift();
657
- // expect(animation.event).toBe("enter");
658
- // expect(animation.element.textContent + "-1").toBe(content + "-1");
659
-
660
- // $state.transitionTo(aState);
661
- // await wait(100);
662
-
663
- // // Enter Animation
664
- // animation = $animate.queue.shift();
665
- // expect(animation.event).toBe("enter");
666
- // expect(animation.element.textContent + "-2").toBe(aState.template + "-2");
667
- // // Leave Animation
668
- // animation = $animate.queue.shift();
669
- // expect(animation.event).toBe("leave");
670
- // expect(animation.element.textContent + "-3").toBe(content + "-3");
671
-
672
- // $state.transitionTo(bState);
673
- // await wait(100);
674
-
675
- // // Enter Animation
676
- // animation = $animate.queue.shift();
677
- // expect(animation.event).toBe("enter");
678
- // expect(animation.element.textContent + "-4").toBe(bState.template + "-4");
679
- // // Leave Animation
680
- // animation = $animate.queue.shift();
681
- // expect(animation.event).toBe("leave");
682
- // expect(animation.element.textContent + "-5").toBe(aState.template + "-5");
683
-
684
- // // No more animations
685
- // expect($animate.queue.length).toBe(0);
686
- // });
687
-
688
- // it("should do ngClass animations", async () => {
689
- // scope.classOn = false;
690
- // let content = "Initial Content",
691
- // className = "yay",
692
- // animation;
693
- // elem.append(
694
- // $compile(
695
- // "<div><ng-view ng-class=\"{'" +
696
- // className +
697
- // "': classOn}\">" +
698
- // content +
699
- // "</ng-view></div>",
700
- // )(scope),
701
- // );
702
- // // Don't care about enter class
703
- // $animate.queue.shift();
704
-
705
- // scope.classOn = true;
706
- // ;
707
-
708
- // animation = $animate.queue.shift();
709
- // expect(animation.event).toBe("addClass");
710
- // expect(animation.element.textContent).toBe(content);
711
-
712
- // scope.classOn = false;
713
- // ;
714
-
715
- // animation = $animate.queue.shift();
716
- // expect(animation.event).toBe("removeClass");
717
- // expect(animation.element.textContent).toBe(content);
718
-
719
- // // No more animations
720
- // expect($animate.queue.length).toBe(0);
721
- // });
722
-
723
- // it("should do ngIf animations", async () => {
724
- // scope.shouldShow = false;
725
- // let content = "Initial Content",
726
- // animation;
727
- // elem.append(
728
- // $compile(
729
- // '<div><ng-view ng-if="shouldShow">' + content + "</ng-view></div>",
730
- // )(scope),
731
- // );
732
-
733
- // // No animations yet
734
- // expect($animate.queue.length).toBe(0);
735
-
736
- // scope.shouldShow = true;
737
- // ;
738
-
739
- // // $ViewDirective enter animation - Basically it's just the <!-- ngView --> comment
740
- // animation = $animate.queue.shift();
741
- // expect(animation.event).toBe("enter");
742
- // expect(animation.element.textContent).toBe("");
743
-
744
- // // $ViewDirectiveFill enter animation - The second ngView directive that files in the content
745
- // animation = $animate.queue.shift();
746
- // expect(animation.event).toBe("enter");
747
- // expect(animation.element.textContent).toBe(content);
748
-
749
- // scope.shouldShow = false;
750
- // ;
751
-
752
- // // ngView leave animation
753
- // animation = $animate.queue.shift();
754
- // expect(animation.event).toBe("leave");
755
- // expect(animation.element.textContent).toBe(content);
756
-
757
- // // No more animations
758
- // expect($animate.queue.length).toBe(0);
759
- // });
760
-
761
- // it("should expose animation promises to controllers", async () => {
762
- // $transitions.onStart({}, function ($transition$) {
763
- // log += "start:" + $transition$.to().name + ";";
764
- // });
765
- // $transitions.onFinish({}, function ($transition$) {
766
- // log += "finish:" + $transition$.to().name + ";";
767
- // });
768
- // $transitions.onSuccess({}, function ($transition$) {
769
- // log += "success:" + $transition$.to().name + ";";
770
- // });
771
-
772
- // const content = "Initial Content";
773
- // elem.append(
774
- // $compile("<div><ng-view>" + content + "</ng-view></div>")(scope),
775
- // );
776
- // $state.transitionTo("n");
777
- // await wait(100);
778
-
779
- // expect($state.current.name).toBe("n");
780
- // expect(log).toBe("start:n;finish:n;success:n;");
781
-
782
- // // animateFlush($animate);
783
- // await wait(100);
784
- // expect(log).toBe("start:n;finish:n;success:n;animEnter;");
785
-
786
- // $state.transitionTo("a");
787
- // await wait(100);
788
- // expect($state.current.name).toBe("a");
789
- // expect(log).toBe(
790
- // "start:n;finish:n;success:n;animEnter;start:a;finish:a;destroy;success:a;",
791
- // );
792
-
793
- // // animateFlush($animate);
794
- // await wait(100);
795
- // expect(log).toBe(
796
- // "start:n;finish:n;success:n;animEnter;start:a;finish:a;destroy;success:a;animLeave;",
797
- // );
798
- // });
799
- // });
800
- });
801
-
802
- describe("ngView named", () => {
803
- let $stateProvider,
804
- scope,
805
- $compile,
806
- elem = document.getElementById("app"),
807
- log,
808
- app,
809
- $injector,
810
- $state,
811
- $rootScope,
812
- $viewScroll;
813
-
814
- beforeEach(() => {
815
- dealoc(document.getElementById("app"));
816
- window.angular = new Angular();
817
- log = "";
818
- app = window.angular
819
- .module("defaultModule", [])
820
- .config((_$stateProvider_) => {
821
- $stateProvider = _$stateProvider_;
822
- $stateProvider
823
- .state({ name: "main", abstract: true, views: { main: {} } })
824
- .state({
825
- name: "main.home",
826
- views: { content: { template: "HOME" } },
827
- })
828
- .state({ name: "test", views: { nest: { template: "TEST" } } });
829
- });
830
-
831
- $injector = window.angular.bootstrap(document.getElementById("app"), [
832
- "defaultModule",
833
- ]);
834
-
835
- $injector.invoke((_$state_, _$rootScope_, _$compile_, _$viewScroll_) => {
836
- $rootScope = _$rootScope_;
837
- scope = $rootScope.$new();
838
- $compile = _$compile_;
839
- $state = _$state_;
840
- $viewScroll = _$viewScroll_;
841
- });
842
- });
843
-
844
- // TODO targetNode not found
845
- it("shouldn't puke on weird nested view setups", async () => {
846
- elem.innerHTML = '<div ng-view="main"><div ng-view="content"></div></div>';
847
- $compile(elem)($rootScope);
848
- await $state.go("main.home");
849
- await wait(100);
850
-
851
- expect($state.current.name).toBe("main.home");
852
- });
853
-
854
- // Test for https://github.com/angular-ui/ui-router/issues/3355
855
- xit("should target weird nested view setups using the view's simple name", async () => {
856
- elem.innerHTML = `
857
- <div>
858
- <div ng-view="main">
859
- MAIN-DEFAULT-
860
- <div ng-view="content">
861
- <div ng-view="nest"></div>
862
- </div>
863
- </div>
864
- </div>
865
- `;
866
- $compile(elem)($rootScope);
867
-
868
- $state.go("test");
869
- await wait(100);
870
-
871
- expect($state.current.name).toBe("test");
872
- expect(elem.textContent.replace(/\s*/g, "")).toBe("MAIN-DEFAULT-TEST");
873
- });
874
- });
875
-
876
- describe("ngView transclusion", () => {
877
- let scope, $compile, elem, $injector, $rootScope, $state;
878
-
879
- beforeEach(() => {
880
- dealoc(document.getElementById("app"));
881
- window.angular = new Angular();
882
- window.angular
883
- .module("defaultModule", [])
884
- .directive("scopeObserver", () => {
885
- return {
886
- restrict: "E",
887
- link: function (scope) {
888
- scope.$emit("directiveCreated");
889
- scope.$on("$destroy", () => {
890
- scope.$emit("directiveDestroyed");
891
- });
892
- },
893
- };
894
- })
895
- .config(function ($stateProvider) {
896
- $stateProvider
897
- .state({
898
- name: "a",
899
- template: "<ng-view><scope-observer></scope-observer></ng-view>",
900
- })
901
- .state({ name: "a.b", template: "anything" });
902
- });
903
- $injector = window.angular.bootstrap(document.getElementById("app"), [
904
- "defaultModule",
905
- ]);
906
-
907
- $injector.invoke((_$state_, _$rootScope_, _$compile_, _$viewScroll_) => {
908
- $rootScope = _$rootScope_;
909
- scope = $rootScope.$new();
910
- $compile = _$compile_;
911
- $state = _$state_;
912
- elem = document.getElementById("app");
913
- });
914
- });
915
-
916
- it("should not link the initial view and leave its scope undestroyed when a subview is activated", async () => {
917
- let aliveCount = 0;
918
- scope.$on("directiveCreated", () => {
919
- aliveCount++;
920
- });
921
- scope.$on("directiveDestroyed", () => {
922
- aliveCount--;
923
- });
924
- elem.innerHTML = "<div><ng-view></ng-view></div>";
925
- $compile(elem)(scope);
926
- $state.transitionTo("a.b");
927
- await wait(100);
928
- expect(aliveCount).toBe(0);
929
- });
930
- });
931
-
932
- describe("ngView controllers or onEnter handlers", () => {
933
- let el, template, scope, count, $rootScope, $compile, $state, elem;
934
-
935
- beforeEach(() => {
936
- dealoc(document.getElementById("app"));
937
- window.angular = new Angular();
938
- window.angular
939
- .module("defaultModule", [])
940
- .config(function ($locationProvider, $stateProvider) {
941
- count = 0;
942
- $locationProvider.html5ModeConf.enabled = false;
943
- $stateProvider
944
- .state({
945
- name: "aside",
946
- url: "/aside",
947
- template: '<div class="aside"></div>',
948
- })
949
- .state({
950
- name: "A",
951
- url: "/A",
952
- template: '<div class="A" ng-view="fwd"></div>',
953
- })
954
- .state({
955
- name: "A.fwd",
956
- url: "/fwd",
957
- views: {
958
- fwd: {
959
- template: '<div class="fwd" ng-view>',
960
- controller: function ($state) {
961
- if (count++ < 20 && $state.current.name == "A.fwd")
962
- $state.go(".nest");
963
- },
964
- },
965
- },
966
- })
967
- .state({
968
- name: "A.fwd.nest",
969
- url: "/nest",
970
- template: '<div class="nest"></div>',
971
- });
972
- });
973
-
974
- let $injector = window.angular.bootstrap(document.getElementById("app"), [
975
- "defaultModule",
976
- ]);
977
-
978
- $injector.invoke((_$state_, _$rootScope_, _$compile_, _$viewScroll_) => {
979
- $rootScope = _$rootScope_;
980
- scope = $rootScope.$new();
981
- $compile = _$compile_;
982
- $state = _$state_;
983
- elem = document.getElementById("app");
984
- });
985
- });
986
-
987
- it("should not go into an infinite loop when controller uses $state.go", async () => {
988
- el = "<div><ng-view></ng-view></div>";
989
- template = $compile(el)($rootScope);
990
- await $state.transitionTo("aside");
991
- await wait(100);
992
- expect(template.querySelector(".aside")).toBeDefined();
993
- expect(template.querySelector(".fwd")).toBeNull();
994
-
995
- await $state.transitionTo("A");
996
- await wait(100);
997
- expect(template.querySelector(".A")).not.toBeNull();
998
- expect(template.querySelector(".fwd")).toBeNull();
999
-
1000
- await $state.transitionTo("A.fwd");
1001
- await wait(100);
1002
- expect(template.querySelector(".A")).not.toBeNull();
1003
- expect(template.querySelector(".fwd")).not.toBeNull();
1004
- expect(template.querySelector(".nest")).not.toBeNull();
1005
- expect(count).toBe(1);
1006
- });
1007
- });
1008
-
1009
- describe("angular 1.5+ style .component()", () => {
1010
- let el = document.getElementById("app"),
1011
- app,
1012
- scope,
1013
- log,
1014
- svcs,
1015
- $stateProvider,
1016
- $templateCache,
1017
- $rootScope;
1018
-
1019
- beforeEach(() => {
1020
- dealoc(document.getElementById("app"));
1021
- window.angular = new Angular();
1022
- window.angular
1023
- .module("defaultModule", [])
1024
- .directive("ng12Directive", () => {
1025
- return {
1026
- restrict: "E",
1027
- scope: { data: "=" },
1028
- templateUrl: "/comp_tpl.html",
1029
- controller: function ($scope) {
1030
- this.data = $scope.data;
1031
- },
1032
- controllerAs: "$ctrl",
1033
- };
1034
- })
1035
- .directive("ng13Directive", () => {
1036
- return {
1037
- scope: { data: "=" },
1038
- templateUrl: "/comp_tpl.html",
1039
- controller: function () {
1040
- this.$onInit = function () {
1041
- log += "onInit;";
1042
- };
1043
- },
1044
- bindToController: true,
1045
- controllerAs: "$ctrl",
1046
- };
1047
- })
1048
- .directive("ng12DynamicDirective", () => {
1049
- return {
1050
- restrict: "E",
1051
- template: "dynamic directive",
1052
- };
1053
- })
1054
- .component("ngComponent", {
1055
- bindings: { data: "<", data2: "<" },
1056
- templateUrl: "/comp_tpl.html",
1057
- controller: function () {
1058
- this.$onInit = function () {
1059
- log += "onInit;";
1060
- };
1061
- },
1062
- })
1063
- .component("header", {
1064
- bindings: { status: "<" },
1065
- template: "#{{ $ctrl.status }}#",
1066
- })
1067
- .component("bindingTypes", {
1068
- bindings: { oneway: "<oneway", twoway: "=", attribute: "@attr" },
1069
- template:
1070
- "-{{ $ctrl.oneway }},{{ $ctrl.twoway }},{{ $ctrl.attribute }}-",
1071
- })
1072
- .component("optionalBindingTypes", {
1073
- bindings: { oneway: "<?oneway", twoway: "=?", attribute: "@?attr" },
1074
- template:
1075
- "-{{ $ctrl.oneway }},{{ $ctrl.twoway }},{{ $ctrl.attribute }}-",
1076
- })
1077
- .component("eventComponent", {
1078
- bindings: { evt: "&" },
1079
- template: "eventCmp",
1080
- })
1081
- .component("mydataComponent", {
1082
- bindings: { dataUser: "<" },
1083
- template: "-{{ $ctrl.dataUser }}-",
1084
- })
1085
- .component("dataComponent", {
1086
- template: "DataComponent",
1087
- })
1088
- .component("parentCallbackComponent", {
1089
- controller: function ($rootScope) {
1090
- this.handleEvent = function (foo, bar) {
1091
- $rootScope.log.push(foo);
1092
- $rootScope.log.push(bar);
1093
- };
1094
- },
1095
- template: `
1096
- <h1>parentCmp</h1>
1097
- <ng-view on-event="$ctrl.handleEvent(foo, bar)"></ng-view>
1098
- `,
1099
- })
1100
- .component("childEventComponent", {
1101
- bindings: { onEvent: "&" },
1102
- template: `
1103
- <h1>childCmp</h1>
1104
- <button id="eventbtn" ng-click="$ctrl.onEvent({ foo: 123, bar: 456 })">Button</button>
1105
- `,
1106
- })
1107
- .component("dynamicComponent", {
1108
- template: "dynamicComponent {{ $ctrl.param }}",
1109
- controller: function () {
1110
- this.uiOnParamsChanged = function (params) {
1111
- this.param = params.param;
1112
- };
1113
- },
1114
- })
1115
- .config(function (_$stateProvider_, $locationProvider) {
1116
- $stateProvider = _$stateProvider_;
1117
- $locationProvider.html5ModeConf.enabled = false;
1118
- });
1119
-
1120
- let $injector = window.angular.bootstrap(document.getElementById("app"), [
1121
- "defaultModule",
1122
- ]);
1123
-
1124
- $injector.invoke((_$rootScope_, _$compile_, _$state_, _$templateCache_) => {
1125
- svcs = {
1126
- $compile: _$compile_,
1127
- $state: _$state_,
1128
- };
1129
- $rootScope = _$rootScope_;
1130
- scope = $rootScope.$new();
1131
- log = "";
1132
- el.innerHTML = "<div><ng-view></ng-view></div>";
1133
- svcs.$compile(el)(scope);
1134
- $templateCache = _$templateCache_;
1135
- });
1136
- });
1137
-
1138
- describe("routing using component templates", () => {
1139
- beforeEach(() => {
1140
- $stateProvider.state({
1141
- name: "cmp_tpl",
1142
- url: "/cmp_tpl",
1143
- templateUrl: "/state_tpl.html",
1144
- controller: function () {},
1145
- resolve: {
1146
- data: function () {
1147
- return "DATA!";
1148
- },
1149
- },
1150
- });
1151
- });
1152
-
1153
- it("should work with directives which themselves have templateUrls", async () => {
1154
- const $state = svcs.$state;
1155
-
1156
- $templateCache.set(
1157
- "/state_tpl.html",
1158
- 'x<ng12-directive data="$resolve.data"></ng12-directive>x',
1159
- );
1160
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1161
-
1162
- $state.transitionTo("cmp_tpl");
1163
- await wait(100);
1164
- expect($state.current.name).toBe("cmp_tpl");
1165
-
1166
- expect(el.querySelector("ng-view").innerHTML).toEqual(
1167
- 'x<ng12-directive data="$resolve.data">-DATA!-</ng12-directive>x',
1168
- );
1169
- });
1170
-
1171
- it("should work with bindToController directives", async () => {
1172
- const $state = svcs.$state;
1173
-
1174
- $templateCache.set(
1175
- "/state_tpl.html",
1176
- 'x<ng13-directive data="$resolve.data"></ng13-directive>x',
1177
- );
1178
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1179
-
1180
- $state.transitionTo("cmp_tpl");
1181
- await wait(100);
1182
-
1183
- expect($state.current.name).toBe("cmp_tpl");
1184
- expect(el.querySelector("ng-view").innerHTML).toEqual(
1185
- 'x<ng13-directive data="$resolve.data">-DATA!-</ng13-directive>x',
1186
- );
1187
- });
1188
-
1189
- it("should work with .component()s", async () => {
1190
- const $state = svcs.$state;
1191
-
1192
- $templateCache.set(
1193
- "/state_tpl.html",
1194
- 'x<ng-component data="$resolve.data"></ng-component>x',
1195
- );
1196
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1197
-
1198
- $state.transitionTo("cmp_tpl");
1199
- await wait(100);
1200
-
1201
- expect($state.current.name).toBe("cmp_tpl");
1202
- expect(el.querySelector("ng-view").innerHTML).toEqual(
1203
- 'x<ng-component data="$resolve.data">-DATA!-</ng-component>x',
1204
- );
1205
- });
1206
- });
1207
-
1208
- describe("+ component: declaration", () => {
1209
- it("should disallow controller/template configuration", () => {
1210
- const stateDef = {
1211
- name: "route2cmp",
1212
- url: "/route2cmp",
1213
- component: "ng12Directive",
1214
- resolve: {
1215
- data: function () {
1216
- return "DATA!";
1217
- },
1218
- },
1219
- };
1220
-
1221
- expect(() => {
1222
- $stateProvider.state(
1223
- Object.assign({ name: "route2cmp", template: "fail" }, stateDef),
1224
- );
1225
- }).toThrow();
1226
- expect(() => {
1227
- $stateProvider.state(
1228
- Object.assign(
1229
- { name: "route2cmp", templateUrl: "fail.html" },
1230
- stateDef,
1231
- ),
1232
- );
1233
- }).toThrow();
1234
- expect(() => {
1235
- $stateProvider.state(
1236
- Object.assign(
1237
- { name: "route2cmp", templateProvider: () => {} },
1238
- stateDef,
1239
- ),
1240
- );
1241
- }).toThrow();
1242
- expect(() => {
1243
- $stateProvider.state(
1244
- Object.assign({ name: "route2cmp", controllerAs: "fail" }, stateDef),
1245
- );
1246
- }).toThrow();
1247
- expect(() => {
1248
- $stateProvider.state(
1249
- Object.assign(
1250
- { name: "route2cmp", controller: "FailCtrl" },
1251
- stateDef,
1252
- ),
1253
- );
1254
- }).toThrow();
1255
- expect(() => {
1256
- $stateProvider.state(
1257
- Object.assign(
1258
- { name: "route2cmp", controllerProvider: function () {} },
1259
- stateDef,
1260
- ),
1261
- );
1262
- }).toThrow();
1263
-
1264
- expect(() => {
1265
- $stateProvider.state(stateDef);
1266
- }).not.toThrow();
1267
- });
1268
-
1269
- it("should work with angular 1.2+ directives", async () => {
1270
- $stateProvider.state({
1271
- name: "route2cmp",
1272
- url: "/route2cmp",
1273
- component: "ng12Directive",
1274
- resolve: {
1275
- data: () => {
1276
- return "DATA!";
1277
- },
1278
- },
1279
- });
1280
-
1281
- const $state = svcs.$state;
1282
-
1283
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1284
- $state.transitionTo("route2cmp");
1285
- await wait(100);
1286
-
1287
- const directiveEl = el.querySelector("div ng-view ng12-directive");
1288
- expect(directiveEl).toBeDefined();
1289
- expect($state.current.name).toBe("route2cmp");
1290
- expect(el.textContent).toBe("-DATA!-");
1291
- });
1292
-
1293
- it("should work with angular 1.3+ bindToComponent directives", async () => {
1294
- $stateProvider.state({
1295
- name: "route2cmp",
1296
- url: "/route2cmp",
1297
- component: "ng13Directive",
1298
- resolve: {
1299
- data: () => {
1300
- return "DATA!";
1301
- },
1302
- },
1303
- });
1304
-
1305
- const $state = svcs.$state;
1306
-
1307
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1308
- $state.transitionTo("route2cmp");
1309
- await wait(100);
1310
-
1311
- const directiveEl = el.querySelector("div ng-view ng13-directive");
1312
- expect(directiveEl).toBeDefined();
1313
- expect($state.current.name).toBe("route2cmp");
1314
- expect(el.textContent).toBe("-DATA!-");
1315
- });
1316
-
1317
- xit("should call $onInit() once", async () => {
1318
- log = "";
1319
- $stateProvider.state({
1320
- name: "route2cmp",
1321
- url: "/route2cmp",
1322
- component: "ng13Directive",
1323
- resolve: {
1324
- data: () => {
1325
- return "DATA!";
1326
- },
1327
- },
1328
- });
1329
-
1330
- const $state = svcs.$state;
1331
-
1332
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1333
- $state.transitionTo("route2cmp");
1334
- await wait(100);
1335
-
1336
- expect(log).toBe("onInit;");
1337
- });
1338
-
1339
- it("should work with angular 1.5+ .component()s", async () => {
1340
- $stateProvider.state({
1341
- name: "route2cmp",
1342
- url: "/route2cmp",
1343
- component: "ngComponent",
1344
- resolve: {
1345
- data: () => {
1346
- return "DATA!";
1347
- },
1348
- },
1349
- });
1350
-
1351
- const $state = svcs.$state;
1352
-
1353
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1354
- $state.transitionTo("route2cmp");
1355
- await wait(100);
1356
-
1357
- const directiveEl = el.querySelector("div ng-view ng-component");
1358
- expect(directiveEl).toBeDefined();
1359
- expect($state.current.name).toBe("route2cmp");
1360
- expect(el.textContent).toBe("-DATA!-");
1361
- });
1362
-
1363
- xit("should only call $onInit() once", async () => {
1364
- $stateProvider.state({
1365
- name: "route2cmp",
1366
- component: "ngComponent",
1367
- resolve: {
1368
- data: () => {
1369
- return "DATA!";
1370
- },
1371
- },
1372
- });
1373
-
1374
- const $state = svcs.$state;
1375
-
1376
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1377
- $state.transitionTo("route2cmp");
1378
- await wait(100);
1379
-
1380
- expect(log).toBe("onInit;");
1381
- });
1382
-
1383
- xit("should only call $onInit() once with componentProvider", async () => {
1384
- $stateProvider.state({
1385
- name: "route2cmp",
1386
- componentProvider: () => "ngComponent",
1387
- resolve: {
1388
- data: () => {
1389
- return "DATA!";
1390
- },
1391
- },
1392
- });
1393
-
1394
- const $state = svcs.$state;
1395
-
1396
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1397
- $state.transitionTo("route2cmp");
1398
- await wait(100);
1399
-
1400
- expect(log).toBe("onInit;");
1401
- });
1402
-
1403
- xit('should supply resolve data to "<", "=", "@" bindings', async () => {
1404
- $stateProvider.state({
1405
- name: "bindingtypes",
1406
- component: "bindingTypes",
1407
- resolve: {
1408
- oneway: () => {
1409
- return "ONEWAY";
1410
- },
1411
- twoway: () => {
1412
- return "TWOWAY";
1413
- },
1414
- attribute: () => {
1415
- return "ATTRIBUTE";
1416
- },
1417
- },
1418
- bindings: { attr: "attribute" },
1419
- });
1420
-
1421
- const $state = svcs.$state;
1422
-
1423
- $state.transitionTo("bindingtypes");
1424
- await wait(100);
1425
-
1426
- expect(el.textContent).toBe("-ONEWAY,TWOWAY,ATTRIBUTE-");
1427
- });
1428
-
1429
- xit('should supply resolve data to optional "<?", "=?", "@?" bindings', async () => {
1430
- $stateProvider.state({
1431
- name: "optionalbindingtypes",
1432
- component: "optionalBindingTypes",
1433
- resolve: {
1434
- oneway: () => {
1435
- return "ONEWAY";
1436
- },
1437
- twoway: () => {
1438
- return "TWOWAY";
1439
- },
1440
- attribute: () => {
1441
- return "ATTRIBUTE";
1442
- },
1443
- },
1444
- bindings: { attr: "attribute" },
1445
- });
1446
-
1447
- const $state = svcs.$state;
1448
-
1449
- $state.transitionTo("optionalbindingtypes");
1450
- await wait(100);
1451
-
1452
- expect(el.textContent).toBe("-ONEWAY,TWOWAY,ATTRIBUTE-");
1453
- });
1454
-
1455
- // Test for #3099
1456
- it('should not throw when routing to a component with output "&" binding', async () => {
1457
- $stateProvider.state({
1458
- name: "nothrow",
1459
- component: "eventComponent",
1460
- });
1461
-
1462
- const $state = svcs.$state;
1463
- $state.transitionTo("nothrow");
1464
- await wait(100);
1465
-
1466
- expect(el.textContent).toBe("eventCmp");
1467
- });
1468
-
1469
- // Test for #3276
1470
- it('should route to a component that is prefixed with "data"', async () => {
1471
- $stateProvider.state({
1472
- name: "data",
1473
- component: "dataComponent",
1474
- });
1475
-
1476
- const $state = svcs.$state;
1477
- $state.transitionTo("data");
1478
- await wait(100);
1479
-
1480
- expect(el.textContent).toBe("DataComponent");
1481
- });
1482
-
1483
- // Test for #3276
1484
- it('should bind a resolve that is prefixed with "data"', async () => {
1485
- $stateProvider.state({
1486
- name: "data",
1487
- component: "mydataComponent",
1488
- resolve: { dataUser: () => "user" },
1489
- });
1490
-
1491
- const $state = svcs.$state;
1492
- $state.transitionTo("data");
1493
- await wait(100);
1494
-
1495
- expect(el.textContent).toBe("-user-");
1496
- });
1497
-
1498
- // Test for #3239
1499
- it("should pass any bindings (wired from a parent component template via the ng-view) through to the child", async () => {
1500
- const $state = svcs.$state;
1501
-
1502
- $stateProvider.state({
1503
- name: "parent",
1504
- template:
1505
- '<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
1506
- controller: function ($scope) {
1507
- $scope.data1w = "1w";
1508
- $scope.data2w = "2w";
1509
- },
1510
- });
1511
-
1512
- $stateProvider.state({
1513
- name: "parent.child",
1514
- component: "bindingTypes",
1515
- });
1516
-
1517
- $state.transitionTo("parent.child");
1518
- await wait(100);
1519
- expect(el.textContent).toEqual("-1w,2w,attrval-");
1520
- });
1521
-
1522
- // Test for #3239
1523
- xit("should prefer ng-view bindings over resolve data", async () => {
1524
- const $state = svcs.$state;
1525
-
1526
- $stateProvider.state({
1527
- name: "parent",
1528
- template:
1529
- '<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
1530
- resolve: {
1531
- oneway: () => "asfasfd",
1532
- twoway: () => "asfasfd",
1533
- attr: () => "asfasfd",
1534
- },
1535
- controller: function ($scope) {
1536
- $scope.data1w = "1w";
1537
- $scope.data2w = "2w";
1538
- },
1539
- });
1540
-
1541
- $stateProvider.state({
1542
- name: "parent.child",
1543
- component: "bindingTypes",
1544
- });
1545
-
1546
- $state.transitionTo("parent.child");
1547
- await wait(100);
1548
- expect(el.textContent).toEqual("-1w,2w,attrval-");
1549
- });
1550
-
1551
- // Test for #3239
1552
- xit("should prefer ng-view bindings over resolve data unless a bindings exists", async () => {
1553
- const $state = svcs.$state;
1554
-
1555
- $stateProvider.state({
1556
- name: "parent",
1557
- template:
1558
- '<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
1559
- resolve: {
1560
- oneway: () => "asfasfd",
1561
- twoway: () => "asfasfd",
1562
- attr: () => "asfasfd",
1563
- },
1564
- controller: function ($scope) {
1565
- $scope.data1w = "1w";
1566
- $scope.data2w = "2w";
1567
- },
1568
- });
1569
-
1570
- $stateProvider.state({
1571
- name: "parent.child",
1572
- component: "bindingTypes",
1573
- bindings: { oneway: "oneway" },
1574
- });
1575
-
1576
- $state.transitionTo("parent.child");
1577
- await wait(100);
1578
- expect(el.textContent).toEqual("-asfasfd,2w,attrval-");
1579
- });
1580
-
1581
- // Test for #3239
1582
- xit("should pass & bindings (wired from a parent component via the ng-view) through to the child", async () => {
1583
- const $state = svcs.$state;
1584
- $rootScope.log = [];
1585
-
1586
- $stateProvider.state({
1587
- name: "parent",
1588
- component: "parentCallbackComponent",
1589
- });
1590
-
1591
- $stateProvider.state({
1592
- name: "parent.child",
1593
- component: "childEventComponent",
1594
- });
1595
-
1596
- $state.transitionTo("parent.child");
1597
- await wait(100);
1598
- expect($rootScope.log).toEqual([]);
1599
- expect(el.textContent.split(/\s+/).filter((x) => x)).toEqual([
1600
- "parentCmp",
1601
- "childCmp",
1602
- "Button",
1603
- ]);
1604
-
1605
- // - Click button
1606
- // - ng-click handler calls $ctrl.onEvent({ foo: 123, bar: 456 })
1607
- // - on-event is bound to $ctrl.handleEvent(foo, bar) on parentCallbackComponent
1608
- // - handleEvent pushes param values to the log
1609
- el.querySelector("button")[0].click();
1610
- expect($rootScope.log).toEqual([123, 456]);
1611
- });
1612
-
1613
- // Test for #3111
1614
- xit("should bind & bindings to a resolve that returns a function", async () => {
1615
- const $state = svcs.$state;
1616
- log = [];
1617
-
1618
- $stateProvider.state({
1619
- name: "resolve",
1620
- component: "childEventComponent",
1621
- resolve: {
1622
- onEvent: () => (foo, bar) => {
1623
- log.push(foo);
1624
- log.push(bar);
1625
- },
1626
- },
1627
- });
1628
-
1629
- $state.transitionTo("resolve");
1630
- await wait(100);
1631
- expect(log).toEqual([]);
1632
- el.querySelector("button")[0].click();
1633
- expect(log).toEqual([123, 456]);
1634
- });
1635
-
1636
- // Test for #3111
1637
- xit("should bind & bindings to a resolve that returns an array-style function", async () => {
1638
- const $state = svcs.$state;
1639
- log = [];
1640
-
1641
- $stateProvider.state({
1642
- name: "resolve",
1643
- component: "childEventComponent",
1644
- resolve: {
1645
- onEvent: () => [
1646
- "foo",
1647
- "bar",
1648
- (foo, bar) => {
1649
- log.push(foo);
1650
- log.push(bar);
1651
- },
1652
- ],
1653
- },
1654
- });
1655
-
1656
- $state.transitionTo("resolve");
1657
- await wait(100);
1658
- expect(log).toEqual([]);
1659
- el.querySelector("button")[0].click();
1660
- expect(log).toEqual([123, 456]);
1661
- });
1662
- });
1663
-
1664
- describe("+ named views with component: declaration", () => {
1665
- let stateDef;
1666
- beforeEach(() => {
1667
- stateDef = {
1668
- name: "route2cmp",
1669
- url: "/route2cmp",
1670
- views: {
1671
- header: { component: "header" },
1672
- content: { component: "ngComponent" },
1673
- },
1674
- resolve: {
1675
- status: () => {
1676
- return "awesome";
1677
- },
1678
- data: () => {
1679
- return "DATA!";
1680
- },
1681
- },
1682
- };
1683
-
1684
- el = createElementFromHTML(
1685
- '<div><div ng-view="header"></div><div ng-view="content"</div>',
1686
- );
1687
- svcs.$compile(el)(scope);
1688
- });
1689
-
1690
- it("should disallow controller/template configuration in the view", () => {
1691
- expect(() => {
1692
- $stateProvider.state(stateDef);
1693
- }).not.toThrow();
1694
- expect(() => {
1695
- const state = Object.assign({}, stateDef);
1696
- state.views.header.template = "fails";
1697
- $stateProvider.state(state);
1698
- }).toThrow();
1699
- });
1700
-
1701
- it("should render components as views", async () => {
1702
- $stateProvider.state(stateDef);
1703
- const $state = svcs.$state;
1704
-
1705
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1706
- $state.transitionTo("route2cmp");
1707
- await wait(100);
1708
-
1709
- const header = el.querySelector("[ng-view=header]");
1710
- const content = el.querySelector("[ng-view=content]");
1711
-
1712
- expect(header.textContent).toBe("#awesome#");
1713
- expect(content.textContent).toBe("-DATA!-");
1714
- });
1715
-
1716
- it("should allow a component view declaration to use a string as a shorthand", async () => {
1717
- stateDef = {
1718
- name: "route2cmp",
1719
- url: "/route2cmp",
1720
- views: { header: "header", content: "ngComponent" },
1721
- resolve: {
1722
- status: () => {
1723
- return "awesome";
1724
- },
1725
- data: () => {
1726
- return "DATA!";
1727
- },
1728
- },
1729
- };
1730
- $stateProvider.state(stateDef);
1731
- const $state = svcs.$state;
1732
-
1733
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1734
- $state.transitionTo("route2cmp");
1735
- await wait(100);
1736
-
1737
- const header = el.querySelector("[ng-view=header]");
1738
- const content = el.querySelector("[ng-view=content]");
1739
-
1740
- expect(header.textContent).toBe("#awesome#");
1741
- expect(content.textContent).toBe("-DATA!-");
1742
- });
1743
-
1744
- // Test for https://github.com/angular-ui/ui-router/issues/3353
1745
- it("should allow different states to reuse view declaration", () => {
1746
- const views = {
1747
- header: { component: "header" },
1748
- content: { component: "ngComponent" },
1749
- };
1750
-
1751
- const stateDef1 = { name: "def1", url: "/def1", views: views };
1752
- const stateDef2 = { name: "def2", url: "/def2", views: views };
1753
-
1754
- $stateProvider.state(stateDef1);
1755
- $stateProvider.state(stateDef2);
1756
- });
1757
- });
1758
-
1759
- describe("+ bindings: declaration", () => {
1760
- it("should provide the named component binding with data from the named resolve", async () => {
1761
- $stateProvider.state({
1762
- name: "route2cmp",
1763
- url: "/route2cmp",
1764
- component: "ng12Directive",
1765
- bindings: { data: "foo" },
1766
- resolve: {
1767
- foo: () => {
1768
- return "DATA!";
1769
- },
1770
- },
1771
- });
1772
-
1773
- const $state = svcs.$state;
1774
-
1775
- $templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
1776
- $state.transitionTo("route2cmp");
1777
- await wait(100);
1778
-
1779
- const directiveEl = el.querySelector("div ng-view ng12-directive");
1780
- expect(directiveEl).toBeDefined();
1781
- expect($state.current.name).toBe("route2cmp");
1782
- expect(el.textContent).toBe("-DATA!-");
1783
- });
1784
-
1785
- it("should provide default bindings for any component bindings omitted in the state.bindings map", async () => {
1786
- $stateProvider.state({
1787
- name: "route2cmp",
1788
- url: "/route2cmp",
1789
- component: "ngComponent",
1790
- bindings: { data: "foo" },
1791
- resolve: {
1792
- foo: () => {
1793
- return "DATA!";
1794
- },
1795
- data2: () => {
1796
- return "DATA2!";
1797
- },
1798
- },
1799
- });
1800
-
1801
- const $state = svcs.$state;
1802
-
1803
- $templateCache.set(
1804
- "/comp_tpl.html",
1805
- "-{{ $ctrl.data }}.{{ $ctrl.data2 }}-",
1806
- );
1807
- $state.transitionTo("route2cmp");
1808
- await wait(100);
1809
-
1810
- const directiveEl = el.querySelector("div ng-view ng-component");
1811
- expect(directiveEl).toBeDefined();
1812
- expect($state.current.name).toBe("route2cmp");
1813
- expect(el.textContent).toBe("-DATA!.DATA2!-");
1814
- });
1815
- });
1816
-
1817
- describe("componentProvider", () => {
1818
- it("should work with angular 1.2+ directives", async () => {
1819
- $stateProvider.state({
1820
- name: "ng12-dynamic-directive",
1821
- url: "/ng12dynamicDirective/:type",
1822
- componentProvider: [
1823
- "$stateParams",
1824
- function ($stateParams) {
1825
- return $stateParams.type;
1826
- },
1827
- ],
1828
- });
1829
-
1830
- const $state = svcs.$state;
1831
-
1832
- $state.transitionTo("ng12-dynamic-directive", {
1833
- type: "ng12DynamicDirective",
1834
- });
1835
- await wait(100);
1836
-
1837
- const directiveEl = el.querySelector(
1838
- "div ng-view ng12-dynamic-directive",
1839
- );
1840
- expect(directiveEl).toBeDefined();
1841
- expect($state.current.name).toBe("ng12-dynamic-directive");
1842
- expect(el.textContent).toBe("dynamic directive");
1843
- });
1844
-
1845
- // TODO Invalid transition
1846
- xit("should load correct component when using componentProvider", async () => {
1847
- $stateProvider.state({
1848
- name: "dynamicComponent",
1849
- url: "/dynamicComponent/:type",
1850
- componentProvider: [
1851
- "$router",
1852
- function ($router) {
1853
- return $router.params.type;
1854
- },
1855
- ],
1856
- });
1857
-
1858
- const $state = svcs.$state;
1859
-
1860
- await $state.transitionTo({
1861
- name: "dynamicComponent",
1862
- type: "dynamicComponent",
1863
- });
1864
- await wait(100);
1865
-
1866
- const directiveEl = el.querySelector("div ng-view dynamic-component");
1867
- expect(directiveEl).toBeDefined();
1868
- expect($state.current.name).toBe("dynamicComponent");
1869
- expect(el.textContent.trim()).toBe("dynamicComponent");
1870
- });
1871
- });
1872
-
1873
- describe("uiOnParamsChanged()", () => {
1874
- let param;
1875
-
1876
- beforeEach(() => {
1877
- param = null;
1878
-
1879
- $stateProvider.state({
1880
- name: "dynamic",
1881
- url: "/dynamic/:param",
1882
- component: "dynamicComponent",
1883
- params: { param: { dynamic: true } },
1884
- });
1885
-
1886
- $stateProvider.state({
1887
- name: "dynamic2",
1888
- url: "/dynamic2/:param",
1889
- componentProvider: () => "dynamicComponent",
1890
- params: { param: { dynamic: true } },
1891
- });
1892
- });
1893
-
1894
- it("should not be called on the initial transition", async () => {
1895
- const $state = svcs.$state;
1896
- $state.go("dynamic", { param: "abc" });
1897
- await wait(100);
1898
- expect(el.textContent.trim()).toBe("dynamicComponent");
1899
- });
1900
-
1901
- xit("should be called when dynamic parameters change", async () => {
1902
- const $state = svcs.$state;
1903
- $state.go("dynamic", { param: "abc" });
1904
- await wait(100);
1905
- $state.go("dynamic", { param: "def" });
1906
- await wait(100);
1907
-
1908
- expect(el.textContent.trim()).toBe("dynamicComponent def");
1909
- });
1910
-
1911
- xit("should work with componentProvider", async () => {
1912
- const $state = svcs.$state;
1913
- $state.go("dynamic2", { param: "abc" });
1914
- await wait(100);
1915
- $state.go("dynamic2", { param: "def" });
1916
- await wait(100);
1917
-
1918
- expect(el.textContent.trim()).toBe("dynamicComponent def");
1919
- });
1920
- });
1921
- });