Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngModelController: trigger change when only property of model changes #5449

Open

Description

@petebacondarwin

Description
If you have an input box that is associated with a model that is an array (or an object), the update machinery ($formatter pipeline and so on) is not triggered if only a property on the array or object changes. This is because ngModelController watches the model without checking objectEquality.

The multiple select input has a kind of hack that triggers a call to $render if the model updates a property but this fails to call the $formatter pipeline. If we push a new option into the array then the select renders OK but a required validator would fail to update.

Reproduction
See this http://plnkr.co/edit/yNFihkAgrVhHYx7lOtMc?p=preview.

Suggested Fix
Asking the NgModelController to watch with object equality would probably be the simplest solution. There may be a performance impact, though since most models are not objects or arrays then this should short-circuit quite quickly for those values.

Angular Version: 1.2.5+

OS: all

Related to : #5337

Activity

  1. changed the title [-]fix(ngModelController): trigger change when only property of model changes[/-] [+]ngModelController: trigger change when only property of model changes[/+] on Dec 10, 2014
  2. antonkarsten commented on Apr 1, 2015

    @antonkarsten

    it seems like this issue is still open. I would like to have a go at fixing it. Is there any new information or planning available for this issue?

    I thought, it might be possible to make the deep-watching configurable through the ngModelOptions (default = false i.e. no deep watching).

  3. self-assigned this
    on Jun 9, 2015
  4. modified the milestones: , on Jun 15, 2015
  5. InsomniacFury commented on Jun 4, 2016

    @InsomniacFury

    It be cool if the option allowed for either deep equality or for it to use a watchCollection under the hood, this keeps it flexible.

    @Narretz @antonkarsten any update on putting this into the next 1.5.x release?

  6. modified the milestones: 1.5.x, on Apr 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions