The view model
An optional object used to create an instance. This overrides the view model's default constructor.
If the ctor option is not flexible enough and you need a very constructed object, this is the right way to setup.
In the following example the factory sets just one property to a distinct value (a pre-fill).
An optional list of handlers, that handle custom binding operations. Assign the name used in n-bind
and an instance of the binder class.
@ViewModel<Model>(Model, { handler: { 'special': new SpecialBinder() }})
In this scenario, the class SpecialBinder must implement IBindingHandler. Any bindings that apply to 'special' are now being re-routed through this custom binder code (exclusively, bypassing the default binders).
Generated using TypeDoc
This type allows various settings for the view. It's optional and all members are optional. A standard view with the view model being build by own code and properties are instantiated, it's usually not required. However, if the model is generated by a tool, such as NSwag, and the initialization steps are not part of the default ctor call, the viewmodel must be "enhanced". There are two options:
The thirs option is regarding handlers. Handlers define, which property is bound in which way. In case you need a special treatment for Date values, create a Handler through implementing the IBindingHandler interface. It has two features: Listen for events and change value if the bound object changes. You can skip the listener part to have an unidirectional binding. Internally there are three pre-defined handlers:
boolean
value and supports thechecked
property instead ofvalue
.