Repository navigation
v0.9.1
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 componentproviders, 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,stateandstorestay 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
nullorundefinedfalls through to it.handlers,functions,validationFunctionsanddirectivesmerge by name, the element winning a name both define; everything else,registryincluded, replaces. A provider nested below another extends it by the same rules. registryis 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/routerwithinjectRouterNavigate({ allow }), anavigatethat passes a spec'sonSuccess: { navigate }path torouter.navigateByUrlonly whenallowlets it through (exact strings,RegExps or a predicate). Whateverallowsays, a path that does not start with a single/is refused: no other origin, nojavascript:or other scheme, no relative path, no backslash or control character.@angular/routeris 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
validateoff, a spec whoserootnames no element now logsroot "…" is not in elements; nothing is rendered.once, instead of rendering nothing in silence. It stays quiet while the spec is loading, and underwarnorstrictthe 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