Skip to content

v0.9.1

Choose a tag to compare

@github-actions github-actions released this 09 Oct 21:16
· 108 commits to main since this release

Set renderer defaults once with provideJsonRender, and let ngx-json-render/router check where a spec navigates.

A chat renders a spec in every message, and binding the same registry and handlers on each <json-render> got old. Both other Angular json-render renderers had a provider for this; now this one does too.

What changes for your app

  • New: provideJsonRender({ registry, handlers, ... }) in application, route or component providers, after which <json-render [spec]="m.spec" /> is enough. Every option input can be provided (registry, fallback, validate, renderLimits, catalog, handlers, onAction, navigate, validationFunctions, functions, directives); spec, loading, state and store stay per element.
  • Pass a function instead of an object and it runs in an injection context, so handlers can inject() your services: provideJsonRender(() => ({ registry, handlers: { cancelOrder: (p) => inject(OrderService).cancel(p['id']) } })).
  • An input bound on the element wins over the provided value; one left null or undefined falls through to it. handlers, functions, validationFunctions and directives merge by name, the element winning a name both define; everything else, registry included, replaces. A provider nested below another extends it by the same rules.
  • registry is no longer a required input. With none bound and none provided, the renderer throws an error that names both ways to supply one, instead of the template failing to compile.
  • New entry point ngx-json-render/router with injectRouterNavigate({ allow }), a navigate that passes a spec's onSuccess: { navigate } path to router.navigateByUrl only when allow lets it through (exact strings, RegExps or a predicate). Whatever allow says, a path that does not start with a single / is refused: no other origin, no javascript: or other scheme, no relative path, no backslash or control character. @angular/router is an optional peer, needed only by this entry point.

Apps that set nothing new see no difference: every existing input keeps its meaning and its default.

Also in this release

  • With validate off, a spec whose root names no element now logs root "…" is not in elements; nothing is rendered. once, instead of rendering nothing in silence. It stays quiet while the spec is loading, and under warn or strict the spec check reports it as before. Thanks to @vns-agm for #17.

Upgrading

npm i ngx-json-render@0.9.1. No catalog release is needed: ngx-json-render-material@0.3.12 peers on ^0.8.0 || ^0.9.0.

Full Changelog: v0.9.0...v0.9.1