@angular-wave/angular.ts 0.9.3 → 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.
- package/@types/angular.d.ts +4 -19
- package/@types/animations/animate.d.ts +2 -2
- package/@types/animations/animation.d.ts +1 -1
- package/@types/core/compile/attributes.d.ts +1 -1
- package/@types/core/compile/compile.d.ts +2 -2
- package/@types/core/controller/controller.d.ts +1 -1
- package/@types/core/controller/interface.d.ts +6 -0
- package/@types/core/di/ng-module.d.ts +27 -26
- package/@types/core/filter/filter.d.ts +5 -5
- package/@types/core/interpolate/interface.d.ts +13 -0
- package/@types/core/interpolate/interpolate.d.ts +1 -13
- package/@types/core/scope/scope.d.ts +4 -1
- package/@types/directive/http/http.d.ts +16 -16
- package/@types/directive/http/interface.d.ts +27 -0
- package/@types/directive/include/include.d.ts +4 -4
- package/@types/directive/inject/inject.d.ts +12 -0
- package/@types/directive/model/model.d.ts +1 -1
- package/@types/directive/script/script.d.ts +2 -2
- package/@types/directive/setter/setter.d.ts +4 -4
- package/@types/filters/filter.d.ts +2 -2
- package/@types/filters/filters.d.ts +2 -2
- package/@types/filters/interface.d.ts +8 -0
- package/@types/filters/limit-to.d.ts +2 -2
- package/@types/filters/order-by.d.ts +2 -2
- package/@types/interface.d.ts +105 -82
- package/@types/namespace.d.ts +76 -0
- package/@types/router/state/interface.d.ts +8 -8
- package/@types/router/state-filters.d.ts +4 -4
- package/@types/router/template-factory.d.ts +8 -8
- package/@types/router/transition/hook-builder.d.ts +5 -2
- package/@types/router/transition/hook-registry.d.ts +11 -2
- package/@types/router/transition/transition-service.d.ts +6 -2
- package/@types/router/transition/transition.d.ts +2 -2
- package/@types/router/view/view.d.ts +1 -8
- package/@types/router/view-scroll.d.ts +4 -2
- package/@types/services/{anchor-scroll.d.ts → anchor-scroll/anchor-scroll.d.ts} +2 -2
- package/@types/services/exception/exception-handler.d.ts +2 -2
- package/@types/services/exception/interface.d.ts +1 -1
- package/@types/services/http/http.d.ts +40 -2
- package/@types/services/http/interface.d.ts +11 -0
- package/@types/services/location/location.d.ts +1 -4
- package/@types/services/sce/sce.d.ts +3 -4
- package/@types/services/template-cache/template-cache.d.ts +4 -4
- package/@types/services/template-request/interface.d.ts +22 -0
- package/@types/services/{template-request.d.ts → template-request/template-request.d.ts} +4 -7
- package/@types/shared/common.d.ts +8 -69
- package/@types/shared/hof.d.ts +7 -7
- package/dist/angular-ts.esm.js +510 -570
- package/dist/angular-ts.umd.js +510 -570
- package/dist/angular-ts.umd.min.js +1 -1
- package/package.json +8 -1
- package/.github/workflows/ci.yml +0 -104
- package/.github/workflows/gh-pages.yml +0 -75
- package/.husky/pre-commit +0 -5
- package/.prettierignore +0 -9
- package/@types/services/cookie-reader.d.ts +0 -4
- package/@types/services/http-backend/http-backend.d.ts +0 -58
- package/@types/services/template-cache/interface.d.ts +0 -10
- package/CHANGELOG.md +0 -17667
- package/CODE_OF_CONDUCT.md +0 -3
- package/CONTRIBUTING.md +0 -247
- package/DEVELOPERS.md +0 -499
- package/Makefile +0 -60
- package/RELEASE.md +0 -86
- package/TRIAGING.md +0 -127
- package/docs/.cspell.yml +0 -8
- package/docs/.github/dependabot.yml +0 -14
- package/docs/.nvmrc +0 -1
- package/docs/CONTRIBUTING.md +0 -28
- package/docs/Dockerfile +0 -4
- package/docs/LICENSE +0 -201
- package/docs/README.md +0 -217
- package/docs/assets/icons/logo.svg +0 -1
- package/docs/assets/scss/_variables_project.scss +0 -12
- package/docs/assets/scss/_variables_project_after_bs.scss +0 -8
- package/docs/assets/scss/index.scss +0 -48
- package/docs/config.yaml +0 -15
- package/docs/content/_index.md +0 -28
- package/docs/content/docs/_index.md +0 -61
- package/docs/content/docs/directive/_index.md +0 -4
- package/docs/content/docs/directive/app.md +0 -11
- package/docs/content/docs/directive/aria.md +0 -0
- package/docs/content/docs/directive/bind.md +0 -72
- package/docs/content/docs/directive/blur.md +0 -38
- package/docs/content/docs/directive/channel.md +0 -37
- package/docs/content/docs/directive/class-even.md +0 -47
- package/docs/content/docs/directive/class-odd.md +0 -48
- package/docs/content/docs/directive/class.md +0 -64
- package/docs/content/docs/directive/click.md +0 -41
- package/docs/content/docs/directive/cloak.md +0 -74
- package/docs/content/docs/directive/copy.md +0 -38
- package/docs/content/docs/directive/cut.md +0 -40
- package/docs/content/docs/directive/dblclick.md +0 -41
- package/docs/content/docs/directive/focus.md +0 -38
- package/docs/content/docs/directive/get.md +0 -203
- package/docs/content/docs/directive/include.md +0 -7
- package/docs/content/docs/directive/keydown.md +0 -38
- package/docs/content/docs/directive/keyup.md +0 -38
- package/docs/content/docs/directive/load.md +0 -43
- package/docs/content/docs/directive/mousedown.md +0 -38
- package/docs/content/docs/directive/mouseenter.md +0 -38
- package/docs/content/docs/directive/mouseleave.md +0 -38
- package/docs/content/docs/directive/mousemove.md +0 -38
- package/docs/content/docs/directive/mouseout.md +0 -38
- package/docs/content/docs/directive/mouseover.md +0 -38
- package/docs/content/docs/directive/mouseup.md +0 -38
- package/docs/content/docs/directive/non-bindable.md +0 -28
- package/docs/content/docs/filter/_index.md +0 -4
- package/docs/content/docs/provider/_index.md +0 -4
- package/docs/content/docs/provider/eventBusProvider.md +0 -35
- package/docs/content/docs/provider/locationProvider.md +0 -26
- package/docs/content/docs/provider/logProvider.md +0 -59
- package/docs/content/docs/provider/templateCacheProvider.md +0 -100
- package/docs/content/docs/service/_index.md +0 -4
- package/docs/content/docs/service/eventBus.md +0 -56
- package/docs/content/docs/service/location.md +0 -57
- package/docs/content/docs/service/log.md +0 -113
- package/docs/content/docs/service/templateCache.md +0 -64
- package/docs/content/docs/service/url.md +0 -5
- package/docs/docker-compose.yaml +0 -12
- package/docs/docsy.work +0 -5
- package/docs/docsy.work.sum +0 -0
- package/docs/go.mod +0 -5
- package/docs/go.sum +0 -6
- package/docs/hugo-disabled.toml +0 -220
- package/docs/hugo.yaml +0 -200
- package/docs/layouts/404.html +0 -13
- package/docs/layouts/_markup/render-heading.html +0 -1
- package/docs/layouts/partials/hooks/head-end.html +0 -3
- package/docs/layouts/shortcodes/showcss.html +0 -2
- package/docs/layouts/shortcodes/showhtml.html +0 -2
- package/docs/layouts/shortcodes/showjs.html +0 -2
- package/docs/layouts/shortcodes/showraw.html +0 -1
- package/docs/layouts/shortcodes/version.html +0 -1
- package/docs/package-lock.json +0 -2293
- package/docs/package.json +0 -53
- package/docs/static/examples/counter/counter-test.html +0 -13
- package/docs/static/examples/counter/counter.html +0 -5
- package/docs/static/examples/counter/counter.test.js +0 -28
- package/docs/static/examples/eventbus/eventbus-test.html +0 -15
- package/docs/static/examples/eventbus/eventbus.html +0 -13
- package/docs/static/examples/eventbus/eventbus.js +0 -15
- package/docs/static/examples/eventbus/eventbus.test.js +0 -19
- package/docs/static/examples/ng-bind/ng-bind.html +0 -9
- package/docs/static/examples/ng-blur/ng-blur.html +0 -9
- package/docs/static/examples/ng-channel/ng-channel-test.html +0 -17
- package/docs/static/examples/ng-channel/ng-channel.html +0 -24
- package/docs/static/examples/ng-channel/ng-channel.test.js +0 -31
- package/docs/static/examples/ng-class/ng-class.html +0 -71
- package/docs/static/examples/ng-class-even/ng-class-even.html +0 -8
- package/docs/static/examples/ng-class-odd/ng-class-odd.html +0 -8
- package/docs/static/examples/ng-click/ng-click.html +0 -6
- package/docs/static/examples/ng-copy/ng-copy.html +0 -6
- package/docs/static/examples/ng-cut/ng-cut.html +0 -6
- package/docs/static/examples/ng-dblclick/ng-dblclick.html +0 -10
- package/docs/static/examples/ng-focus/ng-focus.html +0 -9
- package/docs/static/examples/ng-keydown/ng-keydown.html +0 -9
- package/docs/static/examples/ng-keyup/ng-keyup.html +0 -9
- package/docs/static/examples/ng-load/ng-load.html +0 -8
- package/docs/static/examples/ng-mousedown/ng-mousedown.html +0 -6
- package/docs/static/examples/ng-mouseenter/ng-mouseenter.html +0 -4
- package/docs/static/examples/ng-mouseleave/ng-mouseleave.html +0 -4
- package/docs/static/examples/ng-mousemove/ng-mousemove.html +0 -4
- package/docs/static/examples/ng-mouseout/ng-mouseout.html +0 -4
- package/docs/static/examples/ng-mouseover/ng-mouseover.html +0 -4
- package/docs/static/examples/ng-mouseup/ng-mouseup.html +0 -4
- package/docs/static/examples/ng-non-bindable/ng-non-bindable-test.html +0 -13
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.html +0 -3
- package/docs/static/examples/ng-non-bindable/ng-non-bindable.test.js +0 -11
- package/docs/static/typedoc/.nojekyll +0 -1
- package/docs/static/typedoc/assets/hierarchy.js +0 -1
- package/docs/static/typedoc/assets/highlight.css +0 -78
- package/docs/static/typedoc/assets/icons.js +0 -18
- package/docs/static/typedoc/assets/icons.svg +0 -1
- package/docs/static/typedoc/assets/main.js +0 -60
- package/docs/static/typedoc/assets/navigation.js +0 -1
- package/docs/static/typedoc/assets/search.js +0 -1
- package/docs/static/typedoc/assets/style.css +0 -1633
- package/docs/static/typedoc/classes/Location.html +0 -55
- package/docs/static/typedoc/classes/LocationProvider.html +0 -20
- package/docs/static/typedoc/classes/LogProvider.html +0 -6
- package/docs/static/typedoc/classes/PubSub.html +0 -71
- package/docs/static/typedoc/classes/PubSubProvider.html +0 -3
- package/docs/static/typedoc/classes/TemplateCacheProvider.html +0 -5
- package/docs/static/typedoc/hierarchy.html +0 -1
- package/docs/static/typedoc/index.html +0 -1
- package/docs/static/typedoc/interfaces/ChangesObject.html +0 -6
- package/docs/static/typedoc/interfaces/ComponentOptions.html +0 -16
- package/docs/static/typedoc/interfaces/Controller.html +0 -12
- package/docs/static/typedoc/interfaces/DefaultPorts.html +0 -5
- package/docs/static/typedoc/interfaces/Directive.html +0 -37
- package/docs/static/typedoc/interfaces/DirectivePrePost.html +0 -4
- package/docs/static/typedoc/interfaces/Html5Mode.html +0 -23
- package/docs/static/typedoc/interfaces/HttpHeadersGetter.html +0 -1
- package/docs/static/typedoc/interfaces/HttpProviderDefaults.html +0 -31
- package/docs/static/typedoc/interfaces/HttpRequestConfigHeaders.html +0 -6
- package/docs/static/typedoc/interfaces/HttpRequestTransformer.html +0 -1
- package/docs/static/typedoc/interfaces/HttpResponse.html +0 -7
- package/docs/static/typedoc/interfaces/HttpResponseTransformer.html +0 -1
- package/docs/static/typedoc/interfaces/HttpService.html +0 -38
- package/docs/static/typedoc/interfaces/LogService.html +0 -12
- package/docs/static/typedoc/interfaces/NgModelController.html +0 -30
- package/docs/static/typedoc/interfaces/NgModelOptions.html +0 -16
- package/docs/static/typedoc/interfaces/Provider.html +0 -34
- package/docs/static/typedoc/interfaces/RequestConfig.html +0 -48
- package/docs/static/typedoc/interfaces/RequestShortcutConfig.html +0 -38
- package/docs/static/typedoc/interfaces/ServiceProvider.html +0 -5
- package/docs/static/typedoc/interfaces/TemplateCache.html +0 -7
- package/docs/static/typedoc/interfaces/TranscludeFunctionObject.html +0 -8
- package/docs/static/typedoc/interfaces/UrlParts.html +0 -9
- package/docs/static/typedoc/types/AnnotatedDirectiveFactory.html +0 -1
- package/docs/static/typedoc/types/AnnotatedFactory.html +0 -8
- package/docs/static/typedoc/types/CloneAttachFunction.html +0 -2
- package/docs/static/typedoc/types/ControllerConstructor.html +0 -2
- package/docs/static/typedoc/types/DirectiveCompileFn.html +0 -2
- package/docs/static/typedoc/types/DirectiveController.html +0 -2
- package/docs/static/typedoc/types/DirectiveFactory.html +0 -1
- package/docs/static/typedoc/types/DirectiveFactoryFn.html +0 -1
- package/docs/static/typedoc/types/DirectiveLinkFn.html +0 -2
- package/docs/static/typedoc/types/ExpandoStore.html +0 -2
- package/docs/static/typedoc/types/Expression.html +0 -6
- package/docs/static/typedoc/types/FilterFactory.html +0 -2
- package/docs/static/typedoc/types/FilterFn.html +0 -2
- package/docs/static/typedoc/types/HttpPromise.html +0 -1
- package/docs/static/typedoc/types/HttpResponseStatus.html +0 -1
- package/docs/static/typedoc/types/Injectable.html +0 -4
- package/docs/static/typedoc/types/InjectableClass.html +0 -1
- package/docs/static/typedoc/types/InjectableFactory.html +0 -1
- package/docs/static/typedoc/types/LogCall.html +0 -2
- package/docs/static/typedoc/types/LogServiceFactory.html +0 -2
- package/docs/static/typedoc/types/OnChangesObject.html +0 -2
- package/docs/static/typedoc/types/SwapModeType.html +0 -2
- package/docs/static/typedoc/types/TController.html +0 -2
- package/docs/static/typedoc/types/UrlChangeListener.html +0 -5
- package/docs/static/typedoc/variables/EventBus.html +0 -1
- package/docs/static/typedoc/variables/SwapMode.html +0 -11
- package/docs/static/version.js +0 -13
- package/docs/test-results/.last-run.json +0 -4
- package/docs/test-results/static-examples-counter-counter-counter-example/error-context.md +0 -50
- package/eslint.config.js +0 -26
- package/images/android-chrome-192x192.png +0 -0
- package/images/android-chrome-512x512.png +0 -0
- package/images/apple-touch-icon.png +0 -0
- package/images/favicon-16x16.png +0 -0
- package/images/favicon-32x32.png +0 -0
- package/images/favicon.ico +0 -0
- package/images/site.webmanifest +0 -19
- package/index.html +0 -86
- package/legacy.d.ts +0 -2599
- package/playwright.config.ts +0 -81
- package/public/jasmine/boot0.js +0 -66
- package/public/jasmine/boot1.js +0 -134
- package/public/jasmine/jasmine-html.js +0 -970
- package/public/jasmine/jasmine.css +0 -323
- package/public/jasmine/jasmine.js +0 -11406
- package/public/public/README.md +0 -1
- package/public/public/circle.html +0 -1
- package/public/public/jasmine-helper.css +0 -9
- package/public/public/my_child_directive.html +0 -1
- package/public/public/my_directive.html +0 -1
- package/public/public/my_other_directive.html +0 -1
- package/public/public/test.html +0 -1
- package/rollup.config.js +0 -51
- package/src/angular.js +0 -293
- package/src/angular.spec.js +0 -1191
- package/src/animations/animate-cache.js +0 -80
- package/src/animations/animate-children-directive.js +0 -32
- package/src/animations/animate-children-directive.md +0 -80
- package/src/animations/animate-css-driver.js +0 -284
- package/src/animations/animate-css.html +0 -58
- package/src/animations/animate-css.js +0 -915
- package/src/animations/animate-css.md +0 -263
- package/src/animations/animate-js-driver.js +0 -60
- package/src/animations/animate-js.html +0 -47
- package/src/animations/animate-js.js +0 -371
- package/src/animations/animate-queue.js +0 -859
- package/src/animations/animate-runner.js +0 -193
- package/src/animations/animate-swap.js +0 -33
- package/src/animations/animate-swap.md +0 -88
- package/src/animations/animate.html +0 -19
- package/src/animations/animate.js +0 -546
- package/src/animations/animate.md +0 -933
- package/src/animations/animate.spec.js +0 -490
- package/src/animations/animation.js +0 -519
- package/src/animations/animations.test.js +0 -10
- package/src/animations/interface.ts +0 -19
- package/src/animations/raf-scheduler.html +0 -19
- package/src/animations/raf-scheduler.js +0 -92
- package/src/animations/raf-scheduler.spec.js +0 -98
- package/src/animations/shared.js +0 -341
- package/src/binding.html +0 -19
- package/src/binding.spec.js +0 -474
- package/src/binding.test.js +0 -10
- package/src/core/compile/attributes.js +0 -337
- package/src/core/compile/compile.html +0 -19
- package/src/core/compile/compile.js +0 -3270
- package/src/core/compile/compile.md +0 -1128
- package/src/core/compile/compile.spec.js +0 -15574
- package/src/core/compile/compile.test.js +0 -12
- package/src/core/controller/controller.html +0 -22
- package/src/core/controller/controller.js +0 -189
- package/src/core/controller/controller.spec.js +0 -334
- package/src/core/controller/controller.test.js +0 -12
- package/src/core/core.html +0 -20
- package/src/core/core.test.js +0 -12
- package/src/core/di/injector.html +0 -19
- package/src/core/di/injector.js +0 -307
- package/src/core/di/injector.md +0 -740
- package/src/core/di/injector.spec.js +0 -2310
- package/src/core/di/injector.test.js +0 -12
- package/src/core/di/internal-injector.js +0 -284
- package/src/core/di/ng-module.html +0 -19
- package/src/core/di/ng-module.js +0 -226
- package/src/core/di/ng-module.spec.js +0 -263
- package/src/core/di/ng-module.test.js +0 -12
- package/src/core/filter/filter.html +0 -19
- package/src/core/filter/filter.js +0 -55
- package/src/core/filter/filter.md +0 -132
- package/src/core/filter/filter.spec.js +0 -149
- package/src/core/filter/filter.test.js +0 -12
- package/src/core/interpolate/interpolate.html +0 -22
- package/src/core/interpolate/interpolate.js +0 -408
- package/src/core/interpolate/interpolate.spec.js +0 -601
- package/src/core/interpolate/interpolate.test.js +0 -12
- package/src/core/parse/ast/ast-node.ts +0 -81
- package/src/core/parse/ast/ast.html +0 -19
- package/src/core/parse/ast/ast.js +0 -574
- package/src/core/parse/ast/ast.spec.js +0 -1453
- package/src/core/parse/ast/ast.test.js +0 -10
- package/src/core/parse/ast-type.js +0 -23
- package/src/core/parse/interface.ts +0 -84
- package/src/core/parse/interpreter.js +0 -915
- package/src/core/parse/lexer/lexer.html +0 -19
- package/src/core/parse/lexer/lexer.js +0 -338
- package/src/core/parse/lexer/lexer.spec.js +0 -303
- package/src/core/parse/lexer/lexer.test.js +0 -10
- package/src/core/parse/lexer/token.ts +0 -22
- package/src/core/parse/parse.html +0 -19
- package/src/core/parse/parse.js +0 -337
- package/src/core/parse/parse.md +0 -57
- package/src/core/parse/parse.spec.js +0 -2107
- package/src/core/parse/parse.test.js +0 -10
- package/src/core/parse/parser/parser.html +0 -19
- package/src/core/parse/parser/parser.js +0 -64
- package/src/core/parse/parser/parser.spec.js +0 -8
- package/src/core/parse/parser/parser.test.js +0 -10
- package/src/core/prop.spec.js +0 -775
- package/src/core/root-element.spec.js +0 -14
- package/src/core/sanitize/interface.ts +0 -10
- package/src/core/sanitize/sanitize-uri.js +0 -75
- package/src/core/sanitize/sanitize-uri.spec.js +0 -249
- package/src/core/sanitize/sanitize-uri.test.js +0 -12
- package/src/core/sanitize/sanitize.html +0 -22
- package/src/core/scope/scope.html +0 -19
- package/src/core/scope/scope.js +0 -1249
- package/src/core/scope/scope.spec.js +0 -3000
- package/src/core/scope/scope.test.js +0 -12
- package/src/directive/aria/aria.html +0 -19
- package/src/directive/aria/aria.js +0 -382
- package/src/directive/aria/aria.md +0 -145
- package/src/directive/aria/aria.spec.js +0 -1241
- package/src/directive/aria/aria.test.js +0 -12
- package/src/directive/attrs/attrs.html +0 -19
- package/src/directive/attrs/attrs.js +0 -106
- package/src/directive/attrs/attrs.md +0 -224
- package/src/directive/attrs/attrs.spec.js +0 -71
- package/src/directive/attrs/attrs.test.js +0 -12
- package/src/directive/attrs/boolean.html +0 -19
- package/src/directive/attrs/boolean.spec.js +0 -137
- package/src/directive/attrs/boolean.test.js +0 -12
- package/src/directive/attrs/element-style.html +0 -22
- package/src/directive/attrs/element-style.spec.js +0 -85
- package/src/directive/attrs/element-style.test.js +0 -12
- package/src/directive/attrs/src.html +0 -19
- package/src/directive/attrs/src.spec.js +0 -163
- package/src/directive/attrs/src.test.js +0 -12
- package/src/directive/bind/bind-html.spec.js +0 -36
- package/src/directive/bind/bind.html +0 -20
- package/src/directive/bind/bind.js +0 -78
- package/src/directive/bind/bind.md +0 -142
- package/src/directive/bind/bind.spec.js +0 -314
- package/src/directive/bind/bind.test.js +0 -12
- package/src/directive/channel/channel.html +0 -19
- package/src/directive/channel/channel.js +0 -30
- package/src/directive/channel/channel.spec.js +0 -67
- package/src/directive/channel/channel.test.js +0 -10
- package/src/directive/class/class-test.html +0 -23
- package/src/directive/class/class.html +0 -19
- package/src/directive/class/class.js +0 -184
- package/src/directive/class/class.spec.js +0 -704
- package/src/directive/class/class.test.js +0 -12
- package/src/directive/cloak/cloak.html +0 -19
- package/src/directive/cloak/cloak.js +0 -11
- package/src/directive/cloak/cloak.spec.js +0 -44
- package/src/directive/cloak/cloak.test.js +0 -12
- package/src/directive/controller/controller.html +0 -22
- package/src/directive/controller/controller.js +0 -11
- package/src/directive/controller/controller.md +0 -46
- package/src/directive/controller/controller.spec.js +0 -175
- package/src/directive/controller/controller.test.js +0 -12
- package/src/directive/events/click.spec.js +0 -35
- package/src/directive/events/event.spec.js +0 -267
- package/src/directive/events/events-test.html +0 -36
- package/src/directive/events/events.html +0 -20
- package/src/directive/events/events.js +0 -65
- package/src/directive/events/events.md +0 -125
- package/src/directive/events/events.test.js +0 -12
- package/src/directive/form/form.html +0 -19
- package/src/directive/form/form.js +0 -669
- package/src/directive/form/form.spec.js +0 -1515
- package/src/directive/form/form.test.js +0 -12
- package/src/directive/http/delete.spec.js +0 -26
- package/src/directive/http/form-router-test.html +0 -44
- package/src/directive/http/form-test.html +0 -18
- package/src/directive/http/get.spec.js +0 -488
- package/src/directive/http/http.html +0 -22
- package/src/directive/http/http.js +0 -342
- package/src/directive/http/http.test.js +0 -12
- package/src/directive/http/post-example.html +0 -30
- package/src/directive/http/post.spec.js +0 -521
- package/src/directive/http/put.spec.js +0 -26
- package/src/directive/if/if-animate-css.html +0 -57
- package/src/directive/if/if-animate-svg.html +0 -25
- package/src/directive/if/if.html +0 -19
- package/src/directive/if/if.js +0 -72
- package/src/directive/if/if.md +0 -76
- package/src/directive/if/if.spec.js +0 -293
- package/src/directive/if/if.test.js +0 -114
- package/src/directive/include/include.html +0 -19
- package/src/directive/include/include.js +0 -151
- package/src/directive/include/include.md +0 -87
- package/src/directive/include/include.spec.js +0 -734
- package/src/directive/include/include.test.js +0 -12
- package/src/directive/init/init.html +0 -19
- package/src/directive/init/init.js +0 -22
- package/src/directive/init/init.md +0 -41
- package/src/directive/init/init.spec.js +0 -68
- package/src/directive/init/init.test.js +0 -12
- package/src/directive/input/input-example.html +0 -15
- package/src/directive/input/input.html +0 -19
- package/src/directive/input/input.js +0 -1078
- package/src/directive/input/input.md +0 -706
- package/src/directive/input/input.spec.js +0 -3700
- package/src/directive/input/input.test.js +0 -12
- package/src/directive/messages/messages.html +0 -22
- package/src/directive/messages/messages.js +0 -349
- package/src/directive/messages/messages.md +0 -543
- package/src/directive/messages/messages.spec.js +0 -1083
- package/src/directive/messages/messages.test.js +0 -12
- package/src/directive/model/change.md +0 -25
- package/src/directive/model/model.html +0 -19
- package/src/directive/model/model.js +0 -1170
- package/src/directive/model/model.spec.js +0 -1976
- package/src/directive/model/model.test.js +0 -12
- package/src/directive/model-options/model-option.test.js +0 -12
- package/src/directive/model-options/model-options.html +0 -22
- package/src/directive/model-options/model-options.js +0 -142
- package/src/directive/model-options/model-options.md +0 -407
- package/src/directive/model-options/model-options.spec.js +0 -1022
- package/src/directive/non-bindable/non-bindable.html +0 -22
- package/src/directive/non-bindable/non-bindable.js +0 -9
- package/src/directive/non-bindable/non-bindable.spec.js +0 -59
- package/src/directive/non-bindable/non-bindable.test.js +0 -12
- package/src/directive/observe/observe-demo.html +0 -184
- package/src/directive/observe/observe.html +0 -19
- package/src/directive/observe/observe.js +0 -41
- package/src/directive/observe/observe.spec.js +0 -106
- package/src/directive/observe/observe.test.js +0 -10
- package/src/directive/on/on.html +0 -19
- package/src/directive/on/on.spec.js +0 -215
- package/src/directive/on/on.test.js +0 -12
- package/src/directive/options/options-example.html +0 -17
- package/src/directive/options/options.html +0 -22
- package/src/directive/options/options.js +0 -542
- package/src/directive/options/options.md +0 -179
- package/src/directive/options/options.spec.js +0 -3554
- package/src/directive/options/options.test.js +0 -12
- package/src/directive/ref/href.html +0 -19
- package/src/directive/ref/href.spec.js +0 -141
- package/src/directive/ref/href.test.js +0 -19
- package/src/directive/ref/ref.html +0 -19
- package/src/directive/ref/ref.js +0 -89
- package/src/directive/ref/ref.spec.js +0 -546
- package/src/directive/repeat/repeat.html +0 -19
- package/src/directive/repeat/repeat.js +0 -333
- package/src/directive/repeat/repeat.md +0 -330
- package/src/directive/repeat/repeat.spec.js +0 -1209
- package/src/directive/repeat/repeat.test.js +0 -12
- package/src/directive/script/script.html +0 -19
- package/src/directive/script/script.js +0 -17
- package/src/directive/script/script.md +0 -11
- package/src/directive/script/script.spec.js +0 -47
- package/src/directive/script/script.test.js +0 -12
- package/src/directive/select/select.html +0 -19
- package/src/directive/select/select.js +0 -594
- package/src/directive/select/select.md +0 -74
- package/src/directive/select/select.spec.js +0 -2566
- package/src/directive/select/select.test.js +0 -12
- package/src/directive/setter/setter.html +0 -19
- package/src/directive/setter/setter.js +0 -59
- package/src/directive/setter/setter.spec.js +0 -100
- package/src/directive/setter/setter.test.js +0 -12
- package/src/directive/show-hide/show-hide.html +0 -22
- package/src/directive/show-hide/show-hide.js +0 -65
- package/src/directive/show-hide/show-hide.md +0 -255
- package/src/directive/show-hide/show-hide.spec.js +0 -268
- package/src/directive/show-hide/show-hide.test.js +0 -12
- package/src/directive/style/style.html +0 -19
- package/src/directive/style/style.js +0 -27
- package/src/directive/style/style.md +0 -23
- package/src/directive/style/style.spec.js +0 -183
- package/src/directive/style/style.test.js +0 -12
- package/src/directive/switch/switch.html +0 -19
- package/src/directive/switch/switch.js +0 -133
- package/src/directive/switch/switch.md +0 -66
- package/src/directive/switch/switch.spec.js +0 -509
- package/src/directive/switch/switch.test.js +0 -12
- package/src/directive/transclude/transclude.js +0 -122
- package/src/directive/validators/validators.html +0 -22
- package/src/directive/validators/validators.js +0 -346
- package/src/directive/validators/validators.spec.js +0 -740
- package/src/directive/validators/validators.test.js +0 -12
- package/src/filters/filter.js +0 -213
- package/src/filters/filter.md +0 -69
- package/src/filters/filter.spec.js +0 -719
- package/src/filters/filters.html +0 -22
- package/src/filters/filters.js +0 -239
- package/src/filters/filters.spec.js +0 -36
- package/src/filters/filters.test.js +0 -12
- package/src/filters/json.md +0 -16
- package/src/filters/limit-to.js +0 -55
- package/src/filters/limit-to.md +0 -19
- package/src/filters/limit-to.spec.js +0 -252
- package/src/filters/order-by.js +0 -181
- package/src/filters/order-by.md +0 -83
- package/src/filters/order-by.spec.js +0 -883
- package/src/index.js +0 -6
- package/src/index.spec.js +0 -11
- package/src/injection-tokens.js +0 -78
- package/src/interface.ts +0 -421
- package/src/ng.js +0 -289
- package/src/ng.spec.js +0 -33
- package/src/router/common/trace.js +0 -240
- package/src/router/directives/component-example.html +0 -37
- package/src/router/directives/state-directives.html +0 -22
- package/src/router/directives/state-directives.js +0 -393
- package/src/router/directives/state-directives.md +0 -435
- package/src/router/directives/state-directives.spec.js +0 -1091
- package/src/router/directives/state-directives.test.js +0 -10
- package/src/router/directives/view-directive.js +0 -489
- package/src/router/directives/view-directive.spec.js +0 -1937
- package/src/router/directives/view-directive.test.js +0 -10
- package/src/router/directives/view-directives.html +0 -22
- package/src/router/glob/glob.html +0 -19
- package/src/router/glob/glob.js +0 -102
- package/src/router/glob/glob.spec.js +0 -108
- package/src/router/glob/glob.test.js +0 -12
- package/src/router/hooks/core-resolvables.js +0 -38
- package/src/router/hooks/ignored-transition.js +0 -25
- package/src/router/hooks/invalid-transition.js +0 -14
- package/src/router/hooks/lazy-load.js +0 -104
- package/src/router/hooks/on-enter-exit-retain.js +0 -55
- package/src/router/hooks/redirect-to.js +0 -38
- package/src/router/hooks/resolve.js +0 -57
- package/src/router/hooks/update-globals.js +0 -34
- package/src/router/hooks/url.js +0 -34
- package/src/router/hooks/views.js +0 -41
- package/src/router/params/interface.ts +0 -626
- package/src/router/params/param-factory.js +0 -23
- package/src/router/params/param-type.js +0 -133
- package/src/router/params/param-types.js +0 -153
- package/src/router/params/param.js +0 -243
- package/src/router/params/state-params.js +0 -36
- package/src/router/path/path-node.js +0 -78
- package/src/router/path/path-utils.js +0 -207
- package/src/router/resolve/interface.ts +0 -208
- package/src/router/resolve/resolvable.js +0 -123
- package/src/router/resolve/resolve-context.js +0 -190
- package/src/router/router-test-hashbang.html +0 -45
- package/src/router/router-test.html +0 -41
- package/src/router/router.html +0 -22
- package/src/router/router.js +0 -54
- package/src/router/router.test.js +0 -12
- package/src/router/services.spec.js +0 -52
- package/src/router/state/README.md +0 -21
- package/src/router/state/interface.ts +0 -1007
- package/src/router/state/state-builder.js +0 -376
- package/src/router/state/state-builder.spec.js +0 -86
- package/src/router/state/state-matcher.js +0 -64
- package/src/router/state/state-object.js +0 -118
- package/src/router/state/state-queue-manager.js +0 -95
- package/src/router/state/state-registry.js +0 -257
- package/src/router/state/state-service.js +0 -699
- package/src/router/state/state.html +0 -23
- package/src/router/state/state.spec.js +0 -1002
- package/src/router/state/state.test.js +0 -12
- package/src/router/state/target-state.js +0 -162
- package/src/router/state/views.js +0 -195
- package/src/router/state-filter.spec.js +0 -139
- package/src/router/state-filters.js +0 -46
- package/src/router/template-factory.html +0 -19
- package/src/router/template-factory.js +0 -249
- package/src/router/template-factory.spec.js +0 -155
- package/src/router/template-factory.test.js +0 -12
- package/src/router/transition/hook-builder.js +0 -133
- package/src/router/transition/hook-registry.js +0 -172
- package/src/router/transition/interface.js +0 -18
- package/src/router/transition/interface.ts +0 -922
- package/src/router/transition/reject-factory.js +0 -122
- package/src/router/transition/transition-event-type.js +0 -26
- package/src/router/transition/transition-hook.js +0 -199
- package/src/router/transition/transition-service.js +0 -302
- package/src/router/transition/transition.js +0 -652
- package/src/router/url/url-config.js +0 -155
- package/src/router/url/url-matcher.js +0 -532
- package/src/router/url/url-rule.js +0 -231
- package/src/router/url/url-rules.js +0 -350
- package/src/router/url/url-service.js +0 -446
- package/src/router/url/url-service.spec.js +0 -1288
- package/src/router/url/url.html +0 -19
- package/src/router/url/url.test.js +0 -12
- package/src/router/view/interface.ts +0 -51
- package/src/router/view/view.html +0 -19
- package/src/router/view/view.js +0 -274
- package/src/router/view/view.spec.js +0 -100
- package/src/router/view/view.test.js +0 -12
- package/src/router/view-hook.spec.js +0 -215
- package/src/router/view-scroll.js +0 -33
- package/src/router/view-scroll.spec.js +0 -72
- package/src/services/anchor-scroll.html +0 -76
- package/src/services/anchor-scroll.js +0 -147
- package/src/services/cookie-reader.js +0 -48
- package/src/services/exception/exception-handler.js +0 -75
- package/src/services/exception/interface.ts +0 -7
- package/src/services/http/http.html +0 -23
- package/src/services/http/http.js +0 -922
- package/src/services/http/http.md +0 -413
- package/src/services/http/http.spec.js +0 -3941
- package/src/services/http/http.test.js +0 -11
- package/src/services/http/interface.ts +0 -243
- package/src/services/http/template-request.spec.js +0 -220
- package/src/services/http-backend/http-backend.html +0 -22
- package/src/services/http-backend/http-backend.js +0 -158
- package/src/services/http-backend/http-backend.spec.js +0 -389
- package/src/services/http-backend/http-backend.test.js +0 -12
- package/src/services/location/interface.ts +0 -70
- package/src/services/location/location.html +0 -22
- package/src/services/location/location.js +0 -1006
- package/src/services/location/location.spec.js +0 -3792
- package/src/services/location/location.test.js +0 -12
- package/src/services/log/interface.ts +0 -39
- package/src/services/log/log.html +0 -19
- package/src/services/log/log.js +0 -74
- package/src/services/log/log.spec.js +0 -64
- package/src/services/log/log.test.js +0 -12
- package/src/services/pubsub/pubsub.html +0 -19
- package/src/services/pubsub/pubsub.js +0 -349
- package/src/services/pubsub/pubsub.spec.js +0 -400
- package/src/services/pubsub/pubsub.test.js +0 -12
- package/src/services/sce/sce.html +0 -19
- package/src/services/sce/sce.js +0 -847
- package/src/services/sce/sce.md +0 -300
- package/src/services/sce/sce.spec.js +0 -617
- package/src/services/sce/sce.test.js +0 -12
- package/src/services/template-cache/interface.ts +0 -10
- package/src/services/template-cache/template-cache.html +0 -22
- package/src/services/template-cache/template-cache.js +0 -15
- package/src/services/template-cache/template-cache.spec.js +0 -134
- package/src/services/template-cache/template-cache.test.js +0 -12
- package/src/services/template-request.js +0 -142
- package/src/shared/cache.js +0 -7
- package/src/shared/common.js +0 -438
- package/src/shared/common.spec.js +0 -294
- package/src/shared/constants.js +0 -21
- package/src/shared/dom.js +0 -716
- package/src/shared/hof.js +0 -151
- package/src/shared/hof.spec.js +0 -60
- package/src/shared/interface.ts +0 -21
- package/src/shared/min-err.spec.js +0 -178
- package/src/shared/noderef.js +0 -225
- package/src/shared/predicates.js +0 -34
- package/src/shared/queue.js +0 -105
- package/src/shared/queue.spec.js +0 -80
- package/src/shared/shared.html +0 -24
- package/src/shared/shared.test.js +0 -12
- package/src/shared/strings.js +0 -142
- package/src/shared/strings.spec.js +0 -40
- package/src/shared/test-utils.js +0 -47
- package/src/shared/url-utils/interface.ts +0 -54
- package/src/shared/url-utils/url-utils.html +0 -22
- package/src/shared/url-utils/url-utils.js +0 -122
- package/src/shared/url-utils/url-utils.spec.js +0 -148
- package/src/shared/url-utils/url-utils.test.js +0 -12
- package/src/shared/utils.js +0 -1255
- package/src/shared/utils.spec.js +0 -178
- package/src/src.html +0 -21
- package/src/src.test.js +0 -10
- package/tsconfig.json +0 -19
- package/tsconfig.types.json +0 -14
- package/typedoc.json +0 -8
- package/utils/express.js +0 -203
- package/utils/version.cjs +0 -23
- package/vite.config.js +0 -14
|
@@ -1,1937 +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(
|
|
1125
|
-
(
|
|
1126
|
-
_$rootScope_,
|
|
1127
|
-
_$httpBackend_,
|
|
1128
|
-
_$compile_,
|
|
1129
|
-
_$state_,
|
|
1130
|
-
_$templateCache_,
|
|
1131
|
-
) => {
|
|
1132
|
-
svcs = {
|
|
1133
|
-
$httpBackend: _$httpBackend_,
|
|
1134
|
-
$compile: _$compile_,
|
|
1135
|
-
$state: _$state_,
|
|
1136
|
-
};
|
|
1137
|
-
$rootScope = _$rootScope_;
|
|
1138
|
-
scope = $rootScope.$new();
|
|
1139
|
-
log = "";
|
|
1140
|
-
el.innerHTML = "<div><ng-view></ng-view></div>";
|
|
1141
|
-
svcs.$compile(el)(scope);
|
|
1142
|
-
$templateCache = _$templateCache_;
|
|
1143
|
-
},
|
|
1144
|
-
);
|
|
1145
|
-
});
|
|
1146
|
-
|
|
1147
|
-
describe("routing using component templates", () => {
|
|
1148
|
-
beforeEach(() => {
|
|
1149
|
-
$stateProvider.state({
|
|
1150
|
-
name: "cmp_tpl",
|
|
1151
|
-
url: "/cmp_tpl",
|
|
1152
|
-
templateUrl: "/state_tpl.html",
|
|
1153
|
-
controller: function () {},
|
|
1154
|
-
resolve: {
|
|
1155
|
-
data: function () {
|
|
1156
|
-
return "DATA!";
|
|
1157
|
-
},
|
|
1158
|
-
},
|
|
1159
|
-
});
|
|
1160
|
-
});
|
|
1161
|
-
|
|
1162
|
-
it("should work with directives which themselves have templateUrls", async () => {
|
|
1163
|
-
const $state = svcs.$state;
|
|
1164
|
-
|
|
1165
|
-
$templateCache.set(
|
|
1166
|
-
"/state_tpl.html",
|
|
1167
|
-
'x<ng12-directive data="$resolve.data"></ng12-directive>x',
|
|
1168
|
-
);
|
|
1169
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1170
|
-
|
|
1171
|
-
$state.transitionTo("cmp_tpl");
|
|
1172
|
-
await wait(100);
|
|
1173
|
-
expect($state.current.name).toBe("cmp_tpl");
|
|
1174
|
-
|
|
1175
|
-
expect(el.querySelector("ng-view").innerHTML).toEqual(
|
|
1176
|
-
'x<ng12-directive data="$resolve.data">-DATA!-</ng12-directive>x',
|
|
1177
|
-
);
|
|
1178
|
-
});
|
|
1179
|
-
|
|
1180
|
-
it("should work with bindToController directives", async () => {
|
|
1181
|
-
const $state = svcs.$state;
|
|
1182
|
-
|
|
1183
|
-
$templateCache.set(
|
|
1184
|
-
"/state_tpl.html",
|
|
1185
|
-
'x<ng13-directive data="$resolve.data"></ng13-directive>x',
|
|
1186
|
-
);
|
|
1187
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1188
|
-
|
|
1189
|
-
$state.transitionTo("cmp_tpl");
|
|
1190
|
-
await wait(100);
|
|
1191
|
-
|
|
1192
|
-
expect($state.current.name).toBe("cmp_tpl");
|
|
1193
|
-
expect(el.querySelector("ng-view").innerHTML).toEqual(
|
|
1194
|
-
'x<ng13-directive data="$resolve.data">-DATA!-</ng13-directive>x',
|
|
1195
|
-
);
|
|
1196
|
-
});
|
|
1197
|
-
|
|
1198
|
-
it("should work with .component()s", async () => {
|
|
1199
|
-
const $state = svcs.$state;
|
|
1200
|
-
|
|
1201
|
-
$templateCache.set(
|
|
1202
|
-
"/state_tpl.html",
|
|
1203
|
-
'x<ng-component data="$resolve.data"></ng-component>x',
|
|
1204
|
-
);
|
|
1205
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1206
|
-
|
|
1207
|
-
$state.transitionTo("cmp_tpl");
|
|
1208
|
-
await wait(100);
|
|
1209
|
-
|
|
1210
|
-
expect($state.current.name).toBe("cmp_tpl");
|
|
1211
|
-
expect(el.querySelector("ng-view").innerHTML).toEqual(
|
|
1212
|
-
'x<ng-component data="$resolve.data">-DATA!-</ng-component>x',
|
|
1213
|
-
);
|
|
1214
|
-
});
|
|
1215
|
-
});
|
|
1216
|
-
|
|
1217
|
-
describe("+ component: declaration", () => {
|
|
1218
|
-
it("should disallow controller/template configuration", () => {
|
|
1219
|
-
const stateDef = {
|
|
1220
|
-
name: "route2cmp",
|
|
1221
|
-
url: "/route2cmp",
|
|
1222
|
-
component: "ng12Directive",
|
|
1223
|
-
resolve: {
|
|
1224
|
-
data: function () {
|
|
1225
|
-
return "DATA!";
|
|
1226
|
-
},
|
|
1227
|
-
},
|
|
1228
|
-
};
|
|
1229
|
-
|
|
1230
|
-
expect(() => {
|
|
1231
|
-
$stateProvider.state(
|
|
1232
|
-
Object.assign({ name: "route2cmp", template: "fail" }, stateDef),
|
|
1233
|
-
);
|
|
1234
|
-
}).toThrow();
|
|
1235
|
-
expect(() => {
|
|
1236
|
-
$stateProvider.state(
|
|
1237
|
-
Object.assign(
|
|
1238
|
-
{ name: "route2cmp", templateUrl: "fail.html" },
|
|
1239
|
-
stateDef,
|
|
1240
|
-
),
|
|
1241
|
-
);
|
|
1242
|
-
}).toThrow();
|
|
1243
|
-
expect(() => {
|
|
1244
|
-
$stateProvider.state(
|
|
1245
|
-
Object.assign(
|
|
1246
|
-
{ name: "route2cmp", templateProvider: () => {} },
|
|
1247
|
-
stateDef,
|
|
1248
|
-
),
|
|
1249
|
-
);
|
|
1250
|
-
}).toThrow();
|
|
1251
|
-
expect(() => {
|
|
1252
|
-
$stateProvider.state(
|
|
1253
|
-
Object.assign({ name: "route2cmp", controllerAs: "fail" }, stateDef),
|
|
1254
|
-
);
|
|
1255
|
-
}).toThrow();
|
|
1256
|
-
expect(() => {
|
|
1257
|
-
$stateProvider.state(
|
|
1258
|
-
Object.assign(
|
|
1259
|
-
{ name: "route2cmp", controller: "FailCtrl" },
|
|
1260
|
-
stateDef,
|
|
1261
|
-
),
|
|
1262
|
-
);
|
|
1263
|
-
}).toThrow();
|
|
1264
|
-
expect(() => {
|
|
1265
|
-
$stateProvider.state(
|
|
1266
|
-
Object.assign(
|
|
1267
|
-
{ name: "route2cmp", controllerProvider: function () {} },
|
|
1268
|
-
stateDef,
|
|
1269
|
-
),
|
|
1270
|
-
);
|
|
1271
|
-
}).toThrow();
|
|
1272
|
-
|
|
1273
|
-
expect(() => {
|
|
1274
|
-
$stateProvider.state(stateDef);
|
|
1275
|
-
}).not.toThrow();
|
|
1276
|
-
});
|
|
1277
|
-
|
|
1278
|
-
it("should work with angular 1.2+ directives", async () => {
|
|
1279
|
-
$stateProvider.state({
|
|
1280
|
-
name: "route2cmp",
|
|
1281
|
-
url: "/route2cmp",
|
|
1282
|
-
component: "ng12Directive",
|
|
1283
|
-
resolve: {
|
|
1284
|
-
data: () => {
|
|
1285
|
-
return "DATA!";
|
|
1286
|
-
},
|
|
1287
|
-
},
|
|
1288
|
-
});
|
|
1289
|
-
|
|
1290
|
-
const $state = svcs.$state;
|
|
1291
|
-
|
|
1292
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1293
|
-
$state.transitionTo("route2cmp");
|
|
1294
|
-
await wait(100);
|
|
1295
|
-
|
|
1296
|
-
const directiveEl = el.querySelector("div ng-view ng12-directive");
|
|
1297
|
-
expect(directiveEl).toBeDefined();
|
|
1298
|
-
expect($state.current.name).toBe("route2cmp");
|
|
1299
|
-
expect(el.textContent).toBe("-DATA!-");
|
|
1300
|
-
});
|
|
1301
|
-
|
|
1302
|
-
it("should work with angular 1.3+ bindToComponent directives", async () => {
|
|
1303
|
-
$stateProvider.state({
|
|
1304
|
-
name: "route2cmp",
|
|
1305
|
-
url: "/route2cmp",
|
|
1306
|
-
component: "ng13Directive",
|
|
1307
|
-
resolve: {
|
|
1308
|
-
data: () => {
|
|
1309
|
-
return "DATA!";
|
|
1310
|
-
},
|
|
1311
|
-
},
|
|
1312
|
-
});
|
|
1313
|
-
|
|
1314
|
-
const $state = svcs.$state,
|
|
1315
|
-
$httpBackend = svcs.$httpBackend;
|
|
1316
|
-
|
|
1317
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1318
|
-
$state.transitionTo("route2cmp");
|
|
1319
|
-
await wait(100);
|
|
1320
|
-
|
|
1321
|
-
const directiveEl = el.querySelector("div ng-view ng13-directive");
|
|
1322
|
-
expect(directiveEl).toBeDefined();
|
|
1323
|
-
expect($state.current.name).toBe("route2cmp");
|
|
1324
|
-
expect(el.textContent).toBe("-DATA!-");
|
|
1325
|
-
});
|
|
1326
|
-
|
|
1327
|
-
xit("should call $onInit() once", async () => {
|
|
1328
|
-
log = "";
|
|
1329
|
-
$stateProvider.state({
|
|
1330
|
-
name: "route2cmp",
|
|
1331
|
-
url: "/route2cmp",
|
|
1332
|
-
component: "ng13Directive",
|
|
1333
|
-
resolve: {
|
|
1334
|
-
data: () => {
|
|
1335
|
-
return "DATA!";
|
|
1336
|
-
},
|
|
1337
|
-
},
|
|
1338
|
-
});
|
|
1339
|
-
|
|
1340
|
-
const $state = svcs.$state;
|
|
1341
|
-
|
|
1342
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1343
|
-
$state.transitionTo("route2cmp");
|
|
1344
|
-
await wait(100);
|
|
1345
|
-
|
|
1346
|
-
expect(log).toBe("onInit;");
|
|
1347
|
-
});
|
|
1348
|
-
|
|
1349
|
-
it("should work with angular 1.5+ .component()s", async () => {
|
|
1350
|
-
$stateProvider.state({
|
|
1351
|
-
name: "route2cmp",
|
|
1352
|
-
url: "/route2cmp",
|
|
1353
|
-
component: "ngComponent",
|
|
1354
|
-
resolve: {
|
|
1355
|
-
data: () => {
|
|
1356
|
-
return "DATA!";
|
|
1357
|
-
},
|
|
1358
|
-
},
|
|
1359
|
-
});
|
|
1360
|
-
|
|
1361
|
-
const $state = svcs.$state,
|
|
1362
|
-
$httpBackend = svcs.$httpBackend;
|
|
1363
|
-
|
|
1364
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1365
|
-
$state.transitionTo("route2cmp");
|
|
1366
|
-
await wait(100);
|
|
1367
|
-
|
|
1368
|
-
const directiveEl = el.querySelector("div ng-view ng-component");
|
|
1369
|
-
expect(directiveEl).toBeDefined();
|
|
1370
|
-
expect($state.current.name).toBe("route2cmp");
|
|
1371
|
-
expect(el.textContent).toBe("-DATA!-");
|
|
1372
|
-
});
|
|
1373
|
-
|
|
1374
|
-
xit("should only call $onInit() once", async () => {
|
|
1375
|
-
$stateProvider.state({
|
|
1376
|
-
name: "route2cmp",
|
|
1377
|
-
component: "ngComponent",
|
|
1378
|
-
resolve: {
|
|
1379
|
-
data: () => {
|
|
1380
|
-
return "DATA!";
|
|
1381
|
-
},
|
|
1382
|
-
},
|
|
1383
|
-
});
|
|
1384
|
-
|
|
1385
|
-
const $state = svcs.$state,
|
|
1386
|
-
$httpBackend = svcs.$httpBackend;
|
|
1387
|
-
|
|
1388
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1389
|
-
$state.transitionTo("route2cmp");
|
|
1390
|
-
await wait(100);
|
|
1391
|
-
|
|
1392
|
-
expect(log).toBe("onInit;");
|
|
1393
|
-
});
|
|
1394
|
-
|
|
1395
|
-
xit("should only call $onInit() once with componentProvider", async () => {
|
|
1396
|
-
$stateProvider.state({
|
|
1397
|
-
name: "route2cmp",
|
|
1398
|
-
componentProvider: () => "ngComponent",
|
|
1399
|
-
resolve: {
|
|
1400
|
-
data: () => {
|
|
1401
|
-
return "DATA!";
|
|
1402
|
-
},
|
|
1403
|
-
},
|
|
1404
|
-
});
|
|
1405
|
-
|
|
1406
|
-
const $state = svcs.$state,
|
|
1407
|
-
$httpBackend = svcs.$httpBackend;
|
|
1408
|
-
|
|
1409
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1410
|
-
$state.transitionTo("route2cmp");
|
|
1411
|
-
await wait(100);
|
|
1412
|
-
|
|
1413
|
-
expect(log).toBe("onInit;");
|
|
1414
|
-
});
|
|
1415
|
-
|
|
1416
|
-
xit('should supply resolve data to "<", "=", "@" bindings', async () => {
|
|
1417
|
-
$stateProvider.state({
|
|
1418
|
-
name: "bindingtypes",
|
|
1419
|
-
component: "bindingTypes",
|
|
1420
|
-
resolve: {
|
|
1421
|
-
oneway: () => {
|
|
1422
|
-
return "ONEWAY";
|
|
1423
|
-
},
|
|
1424
|
-
twoway: () => {
|
|
1425
|
-
return "TWOWAY";
|
|
1426
|
-
},
|
|
1427
|
-
attribute: () => {
|
|
1428
|
-
return "ATTRIBUTE";
|
|
1429
|
-
},
|
|
1430
|
-
},
|
|
1431
|
-
bindings: { attr: "attribute" },
|
|
1432
|
-
});
|
|
1433
|
-
|
|
1434
|
-
const $state = svcs.$state,
|
|
1435
|
-
$httpBackend = svcs.$httpBackend;
|
|
1436
|
-
|
|
1437
|
-
$state.transitionTo("bindingtypes");
|
|
1438
|
-
await wait(100);
|
|
1439
|
-
|
|
1440
|
-
expect(el.textContent).toBe("-ONEWAY,TWOWAY,ATTRIBUTE-");
|
|
1441
|
-
});
|
|
1442
|
-
|
|
1443
|
-
xit('should supply resolve data to optional "<?", "=?", "@?" bindings', async () => {
|
|
1444
|
-
$stateProvider.state({
|
|
1445
|
-
name: "optionalbindingtypes",
|
|
1446
|
-
component: "optionalBindingTypes",
|
|
1447
|
-
resolve: {
|
|
1448
|
-
oneway: () => {
|
|
1449
|
-
return "ONEWAY";
|
|
1450
|
-
},
|
|
1451
|
-
twoway: () => {
|
|
1452
|
-
return "TWOWAY";
|
|
1453
|
-
},
|
|
1454
|
-
attribute: () => {
|
|
1455
|
-
return "ATTRIBUTE";
|
|
1456
|
-
},
|
|
1457
|
-
},
|
|
1458
|
-
bindings: { attr: "attribute" },
|
|
1459
|
-
});
|
|
1460
|
-
|
|
1461
|
-
const $state = svcs.$state;
|
|
1462
|
-
|
|
1463
|
-
$state.transitionTo("optionalbindingtypes");
|
|
1464
|
-
await wait(100);
|
|
1465
|
-
|
|
1466
|
-
expect(el.textContent).toBe("-ONEWAY,TWOWAY,ATTRIBUTE-");
|
|
1467
|
-
});
|
|
1468
|
-
|
|
1469
|
-
// Test for #3099
|
|
1470
|
-
it('should not throw when routing to a component with output "&" binding', async () => {
|
|
1471
|
-
$stateProvider.state({
|
|
1472
|
-
name: "nothrow",
|
|
1473
|
-
component: "eventComponent",
|
|
1474
|
-
});
|
|
1475
|
-
|
|
1476
|
-
const $state = svcs.$state;
|
|
1477
|
-
$state.transitionTo("nothrow");
|
|
1478
|
-
await wait(100);
|
|
1479
|
-
|
|
1480
|
-
expect(el.textContent).toBe("eventCmp");
|
|
1481
|
-
});
|
|
1482
|
-
|
|
1483
|
-
// Test for #3276
|
|
1484
|
-
it('should route to a component that is prefixed with "data"', async () => {
|
|
1485
|
-
$stateProvider.state({
|
|
1486
|
-
name: "data",
|
|
1487
|
-
component: "dataComponent",
|
|
1488
|
-
});
|
|
1489
|
-
|
|
1490
|
-
const $state = svcs.$state;
|
|
1491
|
-
$state.transitionTo("data");
|
|
1492
|
-
await wait(100);
|
|
1493
|
-
|
|
1494
|
-
expect(el.textContent).toBe("DataComponent");
|
|
1495
|
-
});
|
|
1496
|
-
|
|
1497
|
-
// Test for #3276
|
|
1498
|
-
it('should bind a resolve that is prefixed with "data"', async () => {
|
|
1499
|
-
$stateProvider.state({
|
|
1500
|
-
name: "data",
|
|
1501
|
-
component: "mydataComponent",
|
|
1502
|
-
resolve: { dataUser: () => "user" },
|
|
1503
|
-
});
|
|
1504
|
-
|
|
1505
|
-
const $state = svcs.$state;
|
|
1506
|
-
$state.transitionTo("data");
|
|
1507
|
-
await wait(100);
|
|
1508
|
-
|
|
1509
|
-
expect(el.textContent).toBe("-user-");
|
|
1510
|
-
});
|
|
1511
|
-
|
|
1512
|
-
// Test for #3239
|
|
1513
|
-
it("should pass any bindings (wired from a parent component template via the ng-view) through to the child", async () => {
|
|
1514
|
-
const $state = svcs.$state;
|
|
1515
|
-
|
|
1516
|
-
$stateProvider.state({
|
|
1517
|
-
name: "parent",
|
|
1518
|
-
template:
|
|
1519
|
-
'<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
|
|
1520
|
-
controller: function ($scope) {
|
|
1521
|
-
$scope.data1w = "1w";
|
|
1522
|
-
$scope.data2w = "2w";
|
|
1523
|
-
},
|
|
1524
|
-
});
|
|
1525
|
-
|
|
1526
|
-
$stateProvider.state({
|
|
1527
|
-
name: "parent.child",
|
|
1528
|
-
component: "bindingTypes",
|
|
1529
|
-
});
|
|
1530
|
-
|
|
1531
|
-
$state.transitionTo("parent.child");
|
|
1532
|
-
await wait(100);
|
|
1533
|
-
expect(el.textContent).toEqual("-1w,2w,attrval-");
|
|
1534
|
-
});
|
|
1535
|
-
|
|
1536
|
-
// Test for #3239
|
|
1537
|
-
xit("should prefer ng-view bindings over resolve data", async () => {
|
|
1538
|
-
const $state = svcs.$state;
|
|
1539
|
-
|
|
1540
|
-
$stateProvider.state({
|
|
1541
|
-
name: "parent",
|
|
1542
|
-
template:
|
|
1543
|
-
'<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
|
|
1544
|
-
resolve: {
|
|
1545
|
-
oneway: () => "asfasfd",
|
|
1546
|
-
twoway: () => "asfasfd",
|
|
1547
|
-
attr: () => "asfasfd",
|
|
1548
|
-
},
|
|
1549
|
-
controller: function ($scope) {
|
|
1550
|
-
$scope.data1w = "1w";
|
|
1551
|
-
$scope.data2w = "2w";
|
|
1552
|
-
},
|
|
1553
|
-
});
|
|
1554
|
-
|
|
1555
|
-
$stateProvider.state({
|
|
1556
|
-
name: "parent.child",
|
|
1557
|
-
component: "bindingTypes",
|
|
1558
|
-
});
|
|
1559
|
-
|
|
1560
|
-
$state.transitionTo("parent.child");
|
|
1561
|
-
await wait(100);
|
|
1562
|
-
expect(el.textContent).toEqual("-1w,2w,attrval-");
|
|
1563
|
-
});
|
|
1564
|
-
|
|
1565
|
-
// Test for #3239
|
|
1566
|
-
xit("should prefer ng-view bindings over resolve data unless a bindings exists", async () => {
|
|
1567
|
-
const $state = svcs.$state;
|
|
1568
|
-
|
|
1569
|
-
$stateProvider.state({
|
|
1570
|
-
name: "parent",
|
|
1571
|
-
template:
|
|
1572
|
-
'<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
|
|
1573
|
-
resolve: {
|
|
1574
|
-
oneway: () => "asfasfd",
|
|
1575
|
-
twoway: () => "asfasfd",
|
|
1576
|
-
attr: () => "asfasfd",
|
|
1577
|
-
},
|
|
1578
|
-
controller: function ($scope) {
|
|
1579
|
-
$scope.data1w = "1w";
|
|
1580
|
-
$scope.data2w = "2w";
|
|
1581
|
-
},
|
|
1582
|
-
});
|
|
1583
|
-
|
|
1584
|
-
$stateProvider.state({
|
|
1585
|
-
name: "parent.child",
|
|
1586
|
-
component: "bindingTypes",
|
|
1587
|
-
bindings: { oneway: "oneway" },
|
|
1588
|
-
});
|
|
1589
|
-
|
|
1590
|
-
$state.transitionTo("parent.child");
|
|
1591
|
-
await wait(100);
|
|
1592
|
-
expect(el.textContent).toEqual("-asfasfd,2w,attrval-");
|
|
1593
|
-
});
|
|
1594
|
-
|
|
1595
|
-
// Test for #3239
|
|
1596
|
-
xit("should pass & bindings (wired from a parent component via the ng-view) through to the child", async () => {
|
|
1597
|
-
const $state = svcs.$state;
|
|
1598
|
-
$rootScope.log = [];
|
|
1599
|
-
|
|
1600
|
-
$stateProvider.state({
|
|
1601
|
-
name: "parent",
|
|
1602
|
-
component: "parentCallbackComponent",
|
|
1603
|
-
});
|
|
1604
|
-
|
|
1605
|
-
$stateProvider.state({
|
|
1606
|
-
name: "parent.child",
|
|
1607
|
-
component: "childEventComponent",
|
|
1608
|
-
});
|
|
1609
|
-
|
|
1610
|
-
$state.transitionTo("parent.child");
|
|
1611
|
-
await wait(100);
|
|
1612
|
-
expect($rootScope.log).toEqual([]);
|
|
1613
|
-
expect(el.textContent.split(/\s+/).filter((x) => x)).toEqual([
|
|
1614
|
-
"parentCmp",
|
|
1615
|
-
"childCmp",
|
|
1616
|
-
"Button",
|
|
1617
|
-
]);
|
|
1618
|
-
|
|
1619
|
-
// - Click button
|
|
1620
|
-
// - ng-click handler calls $ctrl.onEvent({ foo: 123, bar: 456 })
|
|
1621
|
-
// - on-event is bound to $ctrl.handleEvent(foo, bar) on parentCallbackComponent
|
|
1622
|
-
// - handleEvent pushes param values to the log
|
|
1623
|
-
el.querySelector("button")[0].click();
|
|
1624
|
-
expect($rootScope.log).toEqual([123, 456]);
|
|
1625
|
-
});
|
|
1626
|
-
|
|
1627
|
-
// Test for #3111
|
|
1628
|
-
xit("should bind & bindings to a resolve that returns a function", async () => {
|
|
1629
|
-
const $state = svcs.$state;
|
|
1630
|
-
log = [];
|
|
1631
|
-
|
|
1632
|
-
$stateProvider.state({
|
|
1633
|
-
name: "resolve",
|
|
1634
|
-
component: "childEventComponent",
|
|
1635
|
-
resolve: {
|
|
1636
|
-
onEvent: () => (foo, bar) => {
|
|
1637
|
-
log.push(foo);
|
|
1638
|
-
log.push(bar);
|
|
1639
|
-
},
|
|
1640
|
-
},
|
|
1641
|
-
});
|
|
1642
|
-
|
|
1643
|
-
$state.transitionTo("resolve");
|
|
1644
|
-
await wait(100);
|
|
1645
|
-
expect(log).toEqual([]);
|
|
1646
|
-
el.querySelector("button")[0].click();
|
|
1647
|
-
expect(log).toEqual([123, 456]);
|
|
1648
|
-
});
|
|
1649
|
-
|
|
1650
|
-
// Test for #3111
|
|
1651
|
-
xit("should bind & bindings to a resolve that returns an array-style function", async () => {
|
|
1652
|
-
const $state = svcs.$state;
|
|
1653
|
-
log = [];
|
|
1654
|
-
|
|
1655
|
-
$stateProvider.state({
|
|
1656
|
-
name: "resolve",
|
|
1657
|
-
component: "childEventComponent",
|
|
1658
|
-
resolve: {
|
|
1659
|
-
onEvent: () => [
|
|
1660
|
-
"foo",
|
|
1661
|
-
"bar",
|
|
1662
|
-
(foo, bar) => {
|
|
1663
|
-
log.push(foo);
|
|
1664
|
-
log.push(bar);
|
|
1665
|
-
},
|
|
1666
|
-
],
|
|
1667
|
-
},
|
|
1668
|
-
});
|
|
1669
|
-
|
|
1670
|
-
$state.transitionTo("resolve");
|
|
1671
|
-
await wait(100);
|
|
1672
|
-
expect(log).toEqual([]);
|
|
1673
|
-
el.querySelector("button")[0].click();
|
|
1674
|
-
expect(log).toEqual([123, 456]);
|
|
1675
|
-
});
|
|
1676
|
-
});
|
|
1677
|
-
|
|
1678
|
-
describe("+ named views with component: declaration", () => {
|
|
1679
|
-
let stateDef;
|
|
1680
|
-
beforeEach(() => {
|
|
1681
|
-
stateDef = {
|
|
1682
|
-
name: "route2cmp",
|
|
1683
|
-
url: "/route2cmp",
|
|
1684
|
-
views: {
|
|
1685
|
-
header: { component: "header" },
|
|
1686
|
-
content: { component: "ngComponent" },
|
|
1687
|
-
},
|
|
1688
|
-
resolve: {
|
|
1689
|
-
status: () => {
|
|
1690
|
-
return "awesome";
|
|
1691
|
-
},
|
|
1692
|
-
data: () => {
|
|
1693
|
-
return "DATA!";
|
|
1694
|
-
},
|
|
1695
|
-
},
|
|
1696
|
-
};
|
|
1697
|
-
|
|
1698
|
-
el = createElementFromHTML(
|
|
1699
|
-
'<div><div ng-view="header"></div><div ng-view="content"</div>',
|
|
1700
|
-
);
|
|
1701
|
-
svcs.$compile(el)(scope);
|
|
1702
|
-
});
|
|
1703
|
-
|
|
1704
|
-
it("should disallow controller/template configuration in the view", () => {
|
|
1705
|
-
expect(() => {
|
|
1706
|
-
$stateProvider.state(stateDef);
|
|
1707
|
-
}).not.toThrow();
|
|
1708
|
-
expect(() => {
|
|
1709
|
-
const state = Object.assign({}, stateDef);
|
|
1710
|
-
state.views.header.template = "fails";
|
|
1711
|
-
$stateProvider.state(state);
|
|
1712
|
-
}).toThrow();
|
|
1713
|
-
});
|
|
1714
|
-
|
|
1715
|
-
it("should render components as views", async () => {
|
|
1716
|
-
$stateProvider.state(stateDef);
|
|
1717
|
-
const $state = svcs.$state;
|
|
1718
|
-
|
|
1719
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1720
|
-
$state.transitionTo("route2cmp");
|
|
1721
|
-
await wait(100);
|
|
1722
|
-
|
|
1723
|
-
const header = el.querySelector("[ng-view=header]");
|
|
1724
|
-
const content = el.querySelector("[ng-view=content]");
|
|
1725
|
-
|
|
1726
|
-
expect(header.textContent).toBe("#awesome#");
|
|
1727
|
-
expect(content.textContent).toBe("-DATA!-");
|
|
1728
|
-
});
|
|
1729
|
-
|
|
1730
|
-
it("should allow a component view declaration to use a string as a shorthand", async () => {
|
|
1731
|
-
stateDef = {
|
|
1732
|
-
name: "route2cmp",
|
|
1733
|
-
url: "/route2cmp",
|
|
1734
|
-
views: { header: "header", content: "ngComponent" },
|
|
1735
|
-
resolve: {
|
|
1736
|
-
status: () => {
|
|
1737
|
-
return "awesome";
|
|
1738
|
-
},
|
|
1739
|
-
data: () => {
|
|
1740
|
-
return "DATA!";
|
|
1741
|
-
},
|
|
1742
|
-
},
|
|
1743
|
-
};
|
|
1744
|
-
$stateProvider.state(stateDef);
|
|
1745
|
-
const $state = svcs.$state,
|
|
1746
|
-
$httpBackend = svcs.$httpBackend;
|
|
1747
|
-
|
|
1748
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1749
|
-
$state.transitionTo("route2cmp");
|
|
1750
|
-
await wait(100);
|
|
1751
|
-
|
|
1752
|
-
const header = el.querySelector("[ng-view=header]");
|
|
1753
|
-
const content = el.querySelector("[ng-view=content]");
|
|
1754
|
-
|
|
1755
|
-
expect(header.textContent).toBe("#awesome#");
|
|
1756
|
-
expect(content.textContent).toBe("-DATA!-");
|
|
1757
|
-
});
|
|
1758
|
-
|
|
1759
|
-
// Test for https://github.com/angular-ui/ui-router/issues/3353
|
|
1760
|
-
it("should allow different states to reuse view declaration", () => {
|
|
1761
|
-
const views = {
|
|
1762
|
-
header: { component: "header" },
|
|
1763
|
-
content: { component: "ngComponent" },
|
|
1764
|
-
};
|
|
1765
|
-
|
|
1766
|
-
const stateDef1 = { name: "def1", url: "/def1", views: views };
|
|
1767
|
-
const stateDef2 = { name: "def2", url: "/def2", views: views };
|
|
1768
|
-
|
|
1769
|
-
$stateProvider.state(stateDef1);
|
|
1770
|
-
$stateProvider.state(stateDef2);
|
|
1771
|
-
});
|
|
1772
|
-
});
|
|
1773
|
-
|
|
1774
|
-
describe("+ bindings: declaration", () => {
|
|
1775
|
-
it("should provide the named component binding with data from the named resolve", async () => {
|
|
1776
|
-
$stateProvider.state({
|
|
1777
|
-
name: "route2cmp",
|
|
1778
|
-
url: "/route2cmp",
|
|
1779
|
-
component: "ng12Directive",
|
|
1780
|
-
bindings: { data: "foo" },
|
|
1781
|
-
resolve: {
|
|
1782
|
-
foo: () => {
|
|
1783
|
-
return "DATA!";
|
|
1784
|
-
},
|
|
1785
|
-
},
|
|
1786
|
-
});
|
|
1787
|
-
|
|
1788
|
-
const $state = svcs.$state;
|
|
1789
|
-
|
|
1790
|
-
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1791
|
-
$state.transitionTo("route2cmp");
|
|
1792
|
-
await wait(100);
|
|
1793
|
-
|
|
1794
|
-
const directiveEl = el.querySelector("div ng-view ng12-directive");
|
|
1795
|
-
expect(directiveEl).toBeDefined();
|
|
1796
|
-
expect($state.current.name).toBe("route2cmp");
|
|
1797
|
-
expect(el.textContent).toBe("-DATA!-");
|
|
1798
|
-
});
|
|
1799
|
-
|
|
1800
|
-
it("should provide default bindings for any component bindings omitted in the state.bindings map", async () => {
|
|
1801
|
-
$stateProvider.state({
|
|
1802
|
-
name: "route2cmp",
|
|
1803
|
-
url: "/route2cmp",
|
|
1804
|
-
component: "ngComponent",
|
|
1805
|
-
bindings: { data: "foo" },
|
|
1806
|
-
resolve: {
|
|
1807
|
-
foo: () => {
|
|
1808
|
-
return "DATA!";
|
|
1809
|
-
},
|
|
1810
|
-
data2: () => {
|
|
1811
|
-
return "DATA2!";
|
|
1812
|
-
},
|
|
1813
|
-
},
|
|
1814
|
-
});
|
|
1815
|
-
|
|
1816
|
-
const $state = svcs.$state,
|
|
1817
|
-
$httpBackend = svcs.$httpBackend;
|
|
1818
|
-
|
|
1819
|
-
$templateCache.set(
|
|
1820
|
-
"/comp_tpl.html",
|
|
1821
|
-
"-{{ $ctrl.data }}.{{ $ctrl.data2 }}-",
|
|
1822
|
-
);
|
|
1823
|
-
$state.transitionTo("route2cmp");
|
|
1824
|
-
await wait(100);
|
|
1825
|
-
|
|
1826
|
-
const directiveEl = el.querySelector("div ng-view ng-component");
|
|
1827
|
-
expect(directiveEl).toBeDefined();
|
|
1828
|
-
expect($state.current.name).toBe("route2cmp");
|
|
1829
|
-
expect(el.textContent).toBe("-DATA!.DATA2!-");
|
|
1830
|
-
});
|
|
1831
|
-
});
|
|
1832
|
-
|
|
1833
|
-
describe("componentProvider", () => {
|
|
1834
|
-
it("should work with angular 1.2+ directives", async () => {
|
|
1835
|
-
$stateProvider.state({
|
|
1836
|
-
name: "ng12-dynamic-directive",
|
|
1837
|
-
url: "/ng12dynamicDirective/:type",
|
|
1838
|
-
componentProvider: [
|
|
1839
|
-
"$stateParams",
|
|
1840
|
-
function ($stateParams) {
|
|
1841
|
-
return $stateParams.type;
|
|
1842
|
-
},
|
|
1843
|
-
],
|
|
1844
|
-
});
|
|
1845
|
-
|
|
1846
|
-
const $state = svcs.$state;
|
|
1847
|
-
|
|
1848
|
-
$state.transitionTo("ng12-dynamic-directive", {
|
|
1849
|
-
type: "ng12DynamicDirective",
|
|
1850
|
-
});
|
|
1851
|
-
await wait(100);
|
|
1852
|
-
|
|
1853
|
-
const directiveEl = el.querySelector(
|
|
1854
|
-
"div ng-view ng12-dynamic-directive",
|
|
1855
|
-
);
|
|
1856
|
-
expect(directiveEl).toBeDefined();
|
|
1857
|
-
expect($state.current.name).toBe("ng12-dynamic-directive");
|
|
1858
|
-
expect(el.textContent).toBe("dynamic directive");
|
|
1859
|
-
});
|
|
1860
|
-
|
|
1861
|
-
// TODO Invalid transition
|
|
1862
|
-
xit("should load correct component when using componentProvider", async () => {
|
|
1863
|
-
$stateProvider.state({
|
|
1864
|
-
name: "dynamicComponent",
|
|
1865
|
-
url: "/dynamicComponent/:type",
|
|
1866
|
-
componentProvider: [
|
|
1867
|
-
"$router",
|
|
1868
|
-
function ($router) {
|
|
1869
|
-
return $router.params.type;
|
|
1870
|
-
},
|
|
1871
|
-
],
|
|
1872
|
-
});
|
|
1873
|
-
|
|
1874
|
-
const $state = svcs.$state;
|
|
1875
|
-
|
|
1876
|
-
await $state.transitionTo({
|
|
1877
|
-
name: "dynamicComponent",
|
|
1878
|
-
type: "dynamicComponent",
|
|
1879
|
-
});
|
|
1880
|
-
await wait(100);
|
|
1881
|
-
|
|
1882
|
-
const directiveEl = el.querySelector("div ng-view dynamic-component");
|
|
1883
|
-
expect(directiveEl).toBeDefined();
|
|
1884
|
-
expect($state.current.name).toBe("dynamicComponent");
|
|
1885
|
-
expect(el.textContent.trim()).toBe("dynamicComponent");
|
|
1886
|
-
});
|
|
1887
|
-
});
|
|
1888
|
-
|
|
1889
|
-
describe("uiOnParamsChanged()", () => {
|
|
1890
|
-
let param;
|
|
1891
|
-
|
|
1892
|
-
beforeEach(() => {
|
|
1893
|
-
param = null;
|
|
1894
|
-
|
|
1895
|
-
$stateProvider.state({
|
|
1896
|
-
name: "dynamic",
|
|
1897
|
-
url: "/dynamic/:param",
|
|
1898
|
-
component: "dynamicComponent",
|
|
1899
|
-
params: { param: { dynamic: true } },
|
|
1900
|
-
});
|
|
1901
|
-
|
|
1902
|
-
$stateProvider.state({
|
|
1903
|
-
name: "dynamic2",
|
|
1904
|
-
url: "/dynamic2/:param",
|
|
1905
|
-
componentProvider: () => "dynamicComponent",
|
|
1906
|
-
params: { param: { dynamic: true } },
|
|
1907
|
-
});
|
|
1908
|
-
});
|
|
1909
|
-
|
|
1910
|
-
it("should not be called on the initial transition", async () => {
|
|
1911
|
-
const $state = svcs.$state;
|
|
1912
|
-
$state.go("dynamic", { param: "abc" });
|
|
1913
|
-
await wait(100);
|
|
1914
|
-
expect(el.textContent.trim()).toBe("dynamicComponent");
|
|
1915
|
-
});
|
|
1916
|
-
|
|
1917
|
-
xit("should be called when dynamic parameters change", async () => {
|
|
1918
|
-
const $state = svcs.$state;
|
|
1919
|
-
$state.go("dynamic", { param: "abc" });
|
|
1920
|
-
await wait(100);
|
|
1921
|
-
$state.go("dynamic", { param: "def" });
|
|
1922
|
-
await wait(100);
|
|
1923
|
-
|
|
1924
|
-
expect(el.textContent.trim()).toBe("dynamicComponent def");
|
|
1925
|
-
});
|
|
1926
|
-
|
|
1927
|
-
xit("should work with componentProvider", async () => {
|
|
1928
|
-
const $state = svcs.$state;
|
|
1929
|
-
$state.go("dynamic2", { param: "abc" });
|
|
1930
|
-
await wait(100);
|
|
1931
|
-
$state.go("dynamic2", { param: "def" });
|
|
1932
|
-
await wait(100);
|
|
1933
|
-
|
|
1934
|
-
expect(el.textContent.trim()).toBe("dynamicComponent def");
|
|
1935
|
-
});
|
|
1936
|
-
});
|
|
1937
|
-
});
|