Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9235449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:02:06+00:00 2026-06-18T07:02:06+00:00

Code: http://plnkr.co/edit/xPZM5E7tjYqlt5NIabIu?p=preview line-no:17 In this code if I use ctrl.$modelValue = nVal; instead of

  • 0

Code: http://plnkr.co/edit/xPZM5E7tjYqlt5NIabIu?p=preview line-no:17

In this code if I use ctrl.$modelValue = nVal; instead of $parse(attrs.ngModel).assign(scope, nVal); then it does not work. Can you please point-out the reason?

angModule.directive('moChangeProxy', function ($parse) {
    return {
        require:'^ngModel',
        restrict:'A',
        link:function (scope, elm, attrs, ctrl) {
            var proxyExp = attrs.moChangeProxy;            
            scope.$watch(proxyExp, function (nVal) {
                if (nVal != ctrl.$modelValue) {
                    //ctrl.$modelValue = nVal;  // This does not work                  
                    $parse(attrs.ngModel).assign(scope, nVal); // This works well
                }
            });
            elm.bind('blur', function () {
                var proxyVal = scope.$eval(proxyExp);
                if(ctrl.$modelValue != proxyVal) {
                    scope.$apply(function(){
                        $parse(proxyExp).assign(scope, ctrl.$modelValue);
                    });
                }
            });
        }
    };
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T07:02:08+00:00Added an answer on June 18, 2026 at 7:02 am

    I guess that by “does not work” you mean that when the change occurs, it does not run stuff like all the $formatters and update the $viewValue?

    If so, this is because ngModelController watches the “model expression” for changes rather than watching its own $modelValue.

    See these lines: https://github.com/angular/angular.js/blob/master/src/ng/directive/input.js#L1046-L1065

    If you update the model then the watch is triggered and all the machinery gets put into action. If you $modelValue, the ngModelController is not aware of the change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code http://plnkr.co/edit/kiH0Ge?p=preview <!doctype html> <html ng-app=plunker > <head> <meta charset=utf-8> <title>AngularJS
I use this code: http://blogswizards.com/plugin-development/sliding-boxes-and-captions-with-jquery On a simple gallery site I am building. Specifically
In this sample code http://plnkr.co/l6kv7x I want to move the focus into text input
This is my code: http://pastie.org/3915628 On line 25 I have defined the image of
My code is here: http://plnkr.co/edit/2WDK0b Is it possible that when I enter an existing
This is the IMDB code http://pastie.org/private/s8m72fndjvqzdtcjjel5w and in order to use it I must
This is the IMDB code http://pastie.org/private/s8m72fndjvqzdtcjjel5w and in order to use it I must
This code : http://jsfiddle.net/bYtTG/1/ Works as I want in FF, chrome and opera, but
See here for code: http://jsfiddle.net/ecFBK/10/ I'm having a hard time getting this to work
This is my fiddle code http://jsfiddle.net/coderslay/WnC9B/44/ It is successfully plotting the graph. The problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.