Interface NgModelController


@JsType(isNative=true, name="ng.NgModelController", namespace="<global>") public interface NgModelController
Public AngularTS NgModelController contract exposed through the global ng namespace for Closure-annotated applications.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Commit a pending update to the `modelValue`.
    jsinterop.base.JsPropertyMap<Object>
    Public NgModelController.asyncValidators member exposed by the AngularTS namespace contract.
    Public NgModelController.controlName member exposed by the AngularTS namespace contract.
    jsinterop.base.JsPropertyMap<Boolean>
    Public NgModelController.error member exposed by the AngularTS namespace contract.
    elemental2.core.JsArray<Object>
    Public NgModelController.formatters member exposed by the AngularTS namespace contract.
    Public NgModelController.modelValue member exposed by the AngularTS namespace contract.
    Public NgModelController.options member exposed by the AngularTS namespace contract.
    elemental2.core.JsArray<Object>
    Public NgModelController.parsers member exposed by the AngularTS namespace contract.
    jsinterop.base.JsPropertyMap<Boolean>
    Public NgModelController.pending member exposed by the AngularTS namespace contract.
    Public NgModelController.validationMessage member exposed by the AngularTS namespace contract.
    jsinterop.base.JsPropertyMap<Object>
    Public NgModelController.validators member exposed by the AngularTS namespace contract.
    Public NgModelController.validity member exposed by the AngularTS namespace contract.
    elemental2.core.JsArray<Object>
    Public NgModelController.viewChangeListeners member exposed by the AngularTS namespace contract.
    Public NgModelController.viewValue member exposed by the AngularTS namespace contract.
    boolean
    Public NgModelController.dirty member exposed by the AngularTS namespace contract.
    boolean
    isEmpty(Object value)
    This is called when we need to determine if the value of an input is empty.
    boolean
    Public NgModelController.invalid member exposed by the AngularTS namespace contract.
    boolean
    Public NgModelController.pristine member exposed by the AngularTS namespace contract.
    boolean
    Public NgModelController.touched member exposed by the AngularTS namespace contract.
    boolean
    Public NgModelController.untouched member exposed by the AngularTS namespace contract.
    boolean
    Public NgModelController.valid member exposed by the AngularTS namespace contract.
    void
    overrideModelOptions(jsinterop.base.JsPropertyMap<Object> options)
    Override the current model options settings programmatically.
    void
    Runs the model -> view pipeline on the current NgModelController.modelValuemodelValue.
    void
    Called when the view needs to be updated.
    void
    Cancel an update and reset the input element's value to prevent an update to the `modelValue`, which may be caused by a pending debounced event or because the input is waiting for some future event.
    void
    setAsyncValidators(jsinterop.base.JsPropertyMap<Object> asyncValidators)
    Public NgModelController.asyncValidators member exposed by the AngularTS namespace contract.
    default void
    setControlName(double controlName)
     
    default void
    setControlName(String controlName)
     
    void
    Public NgModelController.controlName member exposed by the AngularTS namespace contract.
    void
    Sets the control's single native custom-validity message.
    void
    Sets the control to its dirty state.
    void
    setDirty(boolean dirty)
    Public NgModelController.dirty member exposed by the AngularTS namespace contract.
    void
    setError(jsinterop.base.JsPropertyMap<Boolean> error)
    Public NgModelController.error member exposed by the AngularTS namespace contract.
    void
    setFormatters(elemental2.core.JsArray<Object> formatters)
    Public NgModelController.formatters member exposed by the AngularTS namespace contract.
    void
    setInvalid(boolean invalid)
    Public NgModelController.invalid member exposed by the AngularTS namespace contract.
    void
    setModelValue(Object modelValue)
    Public NgModelController.modelValue member exposed by the AngularTS namespace contract.
    void
    setNativeValidity(boolean state)
    Public NgModelController.setNativeValidity member exposed by the AngularTS namespace contract.
    void
    setOptions(Object options)
    Public NgModelController.options member exposed by the AngularTS namespace contract.
    void
    setParsers(elemental2.core.JsArray<Object> parsers)
    Public NgModelController.parsers member exposed by the AngularTS namespace contract.
    void
    setPending(jsinterop.base.JsPropertyMap<Boolean> pending)
    Public NgModelController.pending member exposed by the AngularTS namespace contract.
    void
    Sets the control to its pristine state.
    void
    setPristine(boolean pristine)
    Public NgModelController.pristine member exposed by the AngularTS namespace contract.
    void
    Sets the control to its touched state.
    void
    setTouched(boolean touched)
    Public NgModelController.touched member exposed by the AngularTS namespace contract.
    void
    Sets the control to its untouched state.
    void
    setUntouched(boolean untouched)
    Public NgModelController.untouched member exposed by the AngularTS namespace contract.
    void
    setValid(boolean valid)
    Public NgModelController.valid member exposed by the AngularTS namespace contract.
    void
    setValidationMessage(String validationMessage)
    Public NgModelController.validationMessage member exposed by the AngularTS namespace contract.
    void
    setValidators(jsinterop.base.JsPropertyMap<Object> validators)
    Public NgModelController.validators member exposed by the AngularTS namespace contract.
    void
    setValidity(String validity)
    Public NgModelController.validity member exposed by the AngularTS namespace contract.
    void
    setValidity(String validationErrorKey, boolean state)
    Updates the validation state of the control and propagates it to the parent form.
    void
    setViewChangeListeners(elemental2.core.JsArray<Object> viewChangeListeners)
    Public NgModelController.viewChangeListeners member exposed by the AngularTS namespace contract.
    void
    setViewValue(Object viewValue)
    Public NgModelController.viewValue member exposed by the AngularTS namespace contract.
    void
    setViewValue(Object value, String trigger)
    Update the view value.
    void
    Runs each of the registered validators (first synchronous validators and then asynchronous validators).
  • Method Details

    • commitViewValue

      void commitViewValue()
      Commit a pending update to the `modelValue`. Updates may be pending by a debounced event or because the input is waiting for a some future event defined in `ng-model-options`. this method is rarely needed as `NgModelController` usually handles calling this in response to input events.
    • getAsyncValidators

      @JsProperty jsinterop.base.JsPropertyMap<Object> getAsyncValidators()
      Public NgModelController.asyncValidators member exposed by the AngularTS namespace contract.
    • getControlName

      @JsProperty NgModelController.GetControlNameUnionType getControlName()
      Public NgModelController.controlName member exposed by the AngularTS namespace contract.
    • getError

      @JsProperty jsinterop.base.JsPropertyMap<Boolean> getError()
      Public NgModelController.error member exposed by the AngularTS namespace contract.
    • getFormatters

      @JsProperty elemental2.core.JsArray<Object> getFormatters()
      Public NgModelController.formatters member exposed by the AngularTS namespace contract.
    • getModelValue

      @JsProperty Object getModelValue()
      Public NgModelController.modelValue member exposed by the AngularTS namespace contract.
    • getOptions

      @JsProperty Object getOptions()
      Public NgModelController.options member exposed by the AngularTS namespace contract.
    • getParsers

      @JsProperty elemental2.core.JsArray<Object> getParsers()
      Public NgModelController.parsers member exposed by the AngularTS namespace contract.
    • getPending

      @JsProperty jsinterop.base.JsPropertyMap<Boolean> getPending()
      Public NgModelController.pending member exposed by the AngularTS namespace contract.
    • getValidationMessage

      @JsProperty String getValidationMessage()
      Public NgModelController.validationMessage member exposed by the AngularTS namespace contract.
    • getValidators

      @JsProperty jsinterop.base.JsPropertyMap<Object> getValidators()
      Public NgModelController.validators member exposed by the AngularTS namespace contract.
    • getValidity

      @JsProperty Object getValidity()
      Public NgModelController.validity member exposed by the AngularTS namespace contract.
    • getViewChangeListeners

      @JsProperty elemental2.core.JsArray<Object> getViewChangeListeners()
      Public NgModelController.viewChangeListeners member exposed by the AngularTS namespace contract.
    • getViewValue

      @JsProperty Object getViewValue()
      Public NgModelController.viewValue member exposed by the AngularTS namespace contract.
    • isDirty

      @JsProperty boolean isDirty()
      Public NgModelController.dirty member exposed by the AngularTS namespace contract.
    • isEmpty

      boolean isEmpty(Object value)
      This is called when we need to determine if the value of an input is empty. For instance, the required directive does this to work out if the input has data or not. The default `isEmpty` function checks whether the value is `undefined`, `''`, `null` or `NaN`. You can override this for input directives whose concept of being empty is different from the default. The `checkboxInputType` directive does this because in its case a value of `false` implies empty.
      Parameters:
      value - The value of the input to check for emptiness.
      Returns:
      Method result.
    • isInvalid

      @JsProperty boolean isInvalid()
      Public NgModelController.invalid member exposed by the AngularTS namespace contract.
    • isPristine

      @JsProperty boolean isPristine()
      Public NgModelController.pristine member exposed by the AngularTS namespace contract.
    • isTouched

      @JsProperty boolean isTouched()
      Public NgModelController.touched member exposed by the AngularTS namespace contract.
    • isUntouched

      @JsProperty boolean isUntouched()
      Public NgModelController.untouched member exposed by the AngularTS namespace contract.
    • isValid

      @JsProperty boolean isValid()
      Public NgModelController.valid member exposed by the AngularTS namespace contract.
    • overrideModelOptions

      void overrideModelOptions(jsinterop.base.JsPropertyMap<Object> options)
      Override the current model options settings programmatically. The previous `ModelOptions` value will not be modified. Instead, a new `ModelOptions` object will inherit from the previous one overriding or inheriting settings that are defined in the given parameter. See `ngModelOptions` for information about what options can be specified and how model option inheritance works. <div class="alert alert-warning"> **Note:** this function only affects the options set on the `ngModelController`, and not the options on the `ngModelOptions` directive from which they might have been obtained initially. </div> <div class="alert alert-danger"> **Note:** it is not possible to override the `getterSetter` option. </div>
      Parameters:
      options - a hash of settings to override the previous options
    • processModelValue

      void processModelValue()
      Runs the model -> view pipeline on the current NgModelController.modelValuemodelValue. The following actions are performed by this method: - the `modelValue` is run through the NgModelController.formattersformatters and the result is set to the NgModelController.viewValueviewValue - the `ng-empty` or `ng-not-empty` class is set on the element - if the `viewValue` has changed: - NgModelController.renderrender is called on the control - the NgModelController.validatorsvalidators are run and the validation status is set. This method is called by ngModel internally when the bound scope value changes. Application developers usually do not have to call this function themselves. This function can be used when the `viewValue` or the rendered DOM value are not correctly formatted and the `modelValue` must be run through the `formatters` again.
    • render

      void render()
      Called when the view needs to be updated. It is expected that the user of the ng-model directive will implement this method. The `render()` method is invoked in the following situations: * `rollbackViewValue()` is called. If we are rolling back the view value to the last committed value then `render()` is called to update the input control. * The value referenced by `ng-model` is changed programmatically and both the `modelValue` and the `viewValue` are different from last time. Since `ng-model` does not do a deep watch, `render()` is only invoked if the values of `modelValue` and `viewValue` are actually different from their previous values. If `modelValue` or `viewValue` are objects (rather than a string or number) then `render()` will not be invoked if you only change a property on the objects.
    • rollbackViewValue

      void rollbackViewValue()
      Cancel an update and reset the input element's value to prevent an update to the `modelValue`, which may be caused by a pending debounced event or because the input is waiting for some future event. If you have an input that uses `ng-model-options` to set up debounced updates or updates that depend on special events such as `blur`, there can be a period when the `viewValue` is out of sync with the ngModel's `modelValue`. In this case, you can use `rollbackViewValue()` to manually cancel the debounced / future update and reset the input to the last committed view value. It is also possible that you run into difficulties if you try to update the ngModel's `modelValue` programmatically before these debounced/future events have resolved/occurred, because AngularTS's dirty checking mechanism is not able to tell whether the model has actually changed or not. The `rollbackViewValue()` method should be called before programmatically changing the model of an input which may have such events pending. This is important in order to make sure that the input field will be updated with the new model value and any pending operations are cancelled.
    • setAsyncValidators

      @JsProperty void setAsyncValidators(jsinterop.base.JsPropertyMap<Object> asyncValidators)
      Public NgModelController.asyncValidators member exposed by the AngularTS namespace contract.
    • setControlName

      @JsProperty void setControlName(NgModelController.GetControlNameUnionType controlName)
      Public NgModelController.controlName member exposed by the AngularTS namespace contract.
    • setControlName

      @JsOverlay default void setControlName(String controlName)
    • setControlName

      @JsOverlay default void setControlName(double controlName)
    • setCustomValidity

      void setCustomValidity(String message)
      Sets the control's single native custom-validity message. Native controls expose this through `ValidityState.customError`; an empty message clears the custom error.
      Parameters:
      message - Value supplied for the message parameter.
    • setDirty

      void setDirty()
      Sets the control to its dirty state. This method can be called to remove the `ng-pristine` class and set the control to its dirty state (`ng-dirty` class). A model is considered to be dirty when the control has been changed from when first compiled.
    • setDirty

      @JsProperty void setDirty(boolean dirty)
      Public NgModelController.dirty member exposed by the AngularTS namespace contract.
    • setError

      @JsProperty void setError(jsinterop.base.JsPropertyMap<Boolean> error)
      Public NgModelController.error member exposed by the AngularTS namespace contract.
    • setFormatters

      @JsProperty void setFormatters(elemental2.core.JsArray<Object> formatters)
      Public NgModelController.formatters member exposed by the AngularTS namespace contract.
    • setInvalid

      @JsProperty void setInvalid(boolean invalid)
      Public NgModelController.invalid member exposed by the AngularTS namespace contract.
    • setModelValue

      @JsProperty void setModelValue(Object modelValue)
      Public NgModelController.modelValue member exposed by the AngularTS namespace contract.
    • setNativeValidity

      void setNativeValidity(boolean state)
      Public NgModelController.setNativeValidity member exposed by the AngularTS namespace contract.
      Parameters:
      state - Value supplied for the state parameter.
    • setOptions

      @JsProperty void setOptions(Object options)
      Public NgModelController.options member exposed by the AngularTS namespace contract.
    • setParsers

      @JsProperty void setParsers(elemental2.core.JsArray<Object> parsers)
      Public NgModelController.parsers member exposed by the AngularTS namespace contract.
    • setPending

      @JsProperty void setPending(jsinterop.base.JsPropertyMap<Boolean> pending)
      Public NgModelController.pending member exposed by the AngularTS namespace contract.
    • setPristine

      void setPristine()
      Sets the control to its pristine state. This method can be called to remove the `ng-dirty` class and set the control to its pristine state (`ng-pristine` class). A model is considered to be pristine when the control has not been changed from when first compiled.
    • setPristine

      @JsProperty void setPristine(boolean pristine)
      Public NgModelController.pristine member exposed by the AngularTS namespace contract.
    • setTouched

      void setTouched()
      Sets the control to its touched state. This method can be called to remove the `ng-untouched` class and set the control to its touched state (`ng-touched` class). A model is considered to be touched when the user has first focused the control element and then shifted focus away from the control (blur event).
    • setTouched

      @JsProperty void setTouched(boolean touched)
      Public NgModelController.touched member exposed by the AngularTS namespace contract.
    • setUntouched

      void setUntouched()
      Sets the control to its untouched state. This method can be called to remove the `ng-touched` class and set the control to its untouched state (`ng-untouched` class). Upon compilation, a model is set as untouched by default, however this function can be used to restore that state if the model has already been touched by the user.
    • setUntouched

      @JsProperty void setUntouched(boolean untouched)
      Public NgModelController.untouched member exposed by the AngularTS namespace contract.
    • setValid

      @JsProperty void setValid(boolean valid)
      Public NgModelController.valid member exposed by the AngularTS namespace contract.
    • setValidationMessage

      @JsProperty void setValidationMessage(String validationMessage)
      Public NgModelController.validationMessage member exposed by the AngularTS namespace contract.
    • setValidators

      @JsProperty void setValidators(jsinterop.base.JsPropertyMap<Object> validators)
      Public NgModelController.validators member exposed by the AngularTS namespace contract.
    • setValidity

      @JsProperty void setValidity(String validity)
      Public NgModelController.validity member exposed by the AngularTS namespace contract.
    • setValidity

      void setValidity(String validationErrorKey, boolean state)
      Updates the validation state of the control and propagates it to the parent form.
      Parameters:
      validationErrorKey - Value supplied for the validationErrorKey parameter.
      state - Value supplied for the state parameter.
    • setViewChangeListeners

      @JsProperty void setViewChangeListeners(elemental2.core.JsArray<Object> viewChangeListeners)
      Public NgModelController.viewChangeListeners member exposed by the AngularTS namespace contract.
    • setViewValue

      void setViewValue(Object value, String trigger)
      Update the view value. This method should be called when a control wants to change the view value; typically, this is done from within a DOM event handler. For example, the `input` directive calls it when the value of the input changes and `select` calls it when an option is selected. When `setViewValue` is called, the new `value` will be staged for committing through the `parsers` and `validators` pipelines. If there are no special `ngModelOptions` settings specified then the staged value is sent directly for processing through the `parsers` pipeline. After this, the `validators` and `asyncValidators` are called and the value is applied to `modelValue`. Finally, the value is set to the **expression** specified in the `ng-model` attribute and all the registered change listeners, in the `viewChangeListeners` list are called. In case the `ngModelOptions` directive is used with `updateOn` and the `default` trigger is not listed, all those actions will remain pending until one of the `updateOn` events is triggered on the DOM element. All these actions will be debounced if the `ngModelOptions` directive is used with a custom debounce for this particular event. The model commit and its reactive notifications run when an `updateOn` event fires, or after the configured debounce timer expires. Standard native inputs pass through browser-native values, such as strings from text-like controls, booleans from checkboxes, and `FileList | null` from file inputs. However, custom controls might also pass objects to this method. In this case, we should make a copy of the object before passing it to `setViewValue`. This is because `ngModel` does not perform a deep watch of objects, it only looks for a change of identity. If you only change the property of the object then ngModel will not realize that the object has changed and will not invoke the `parsers` and `validators` pipelines. For this reason, you should not change properties of the copy once it has been passed to `setViewValue`. Otherwise you may cause the model value on the scope to change incorrectly. <div class="alert alert-info"> In any case, the value passed to the method should always reflect the current value of the control. For example, if you are calling `setViewValue` for an input element, you should pass the input DOM value. Otherwise, the control and the scope model become out of sync. It's also important to note that `setViewValue` does not call `render` or change the control's DOM value in any way. If we want to change the control's DOM value programmatically, we should update the `ngModel` scope expression. Its new value will be picked up by the model controller, which will run it through the `formatters`, `render` it to update the DOM, and finally call `validate` on it. </div>
      Parameters:
      value - value from the view.
      trigger - Event that triggered the update.
    • setViewValue

      @JsProperty void setViewValue(Object viewValue)
      Public NgModelController.viewValue member exposed by the AngularTS namespace contract.
    • validate

      void validate()
      Runs each of the registered validators (first synchronous validators and then asynchronous validators). If the validity changes to invalid, the model will be set to `undefined`, unless `ngModelOptions.allowInvalid` is `true`. If the validity changes to valid, it will set the model to the last available valid `modelValue`, i.e. either the last parsed value or the last value set from the scope.