initializeModelAdapter
since v1.1.0initializeModelAdapter(
adapter,model?,injector?,options?):ModelAdapter
Initializes an existing model adapter for use in ng-diagram.
Prepares all nodes and edges in the adapter so they are ready for rendering by ng-diagram. Use this when providing a custom ModelAdapter implementation.
Parameters
Section titled “Parameters”adapter
Section titled “adapter”An existing ModelAdapter to initialize.
model?
Section titled “model?”Partial<Model>
Optional initial model data to seed the adapter with.
injector?
Section titled “injector?”Injector
Optional Angular Injector if not running inside an injection context.
options?
Section titled “options?”Optional InitializeModelOptions. ⚠️ Overriding the strip
functions can and probably will break the diagram — use at your own risk. Note
that for custom adapters these functions only affect initialization; keeping
serialization consistent in your adapter’s toJSON() is up to you.
Returns
Section titled “Returns”Example
Section titled “Example”// Basic usage with a custom adaptermodel = initializeModelAdapter(new NgRxModelAdapter(this.store));
// With initial model data to seed the adaptermodel = initializeModelAdapter(new NgRxModelAdapter(this.store), { nodes: [{ id: '1', position: { x: 0, y: 0 }, data: { label: 'Node 1' } }], edges: [],});
// With an explicit injector (outside injection context)model = initializeModelAdapter(new NgRxModelAdapter(this.store), undefined, this.injector);Version History
Section titled “Version History”| Version | Changes |
|---|---|
| v1.1.0 | Introduced |
| v1.3.0 | Added options parameter for customizing runtime-property stripping |