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 8515953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:17:14+00:00 2026-06-11T05:17:14+00:00

In AngularJS scope.$apply() is called on every event handler (keydown/input events for input directive,

  • 0

In AngularJS scope.$apply() is called on every event handler (keydown/input events for input directive, change event for select directive, etc) and some other cases.

See small example. Seems that ngRepeat is recalculated and redrawn on every keydown despite the fact that changes occur in the other scope.

It would be interesting to know rationale for such decision.

  • 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-11T05:17:15+00:00Added an answer on June 11, 2026 at 5:17 am

    Would be great to have AngularJS authors on this but I believe that the $digest() needs to be called on the $rootScope since changes triggered in a repeater’s can have side-effects in other scopes (even the $rootScope).

    The thing is that methods triggered in child scopes can influence objects in parent scopes (since child scopes inherit from parent ones). So, even if functions defined in child scopes can’t modify object references from a parent scope they still can modify values in objects defined in a parent scope.

    The above might sound a bit cryptic so let’s consider an (a bit artificial) example with a list of items:

    $scope.items = [{name: 'foo', value:0}, {name: 'bar', value:0}, {name: 'baz', value:0}];
    

    Now, let’s use ng-Repeat to display the above list and let’s say that clicking on a item should increment a value of other items (once again, the example is a bit artificial but the point here is that an action triggered in one scope can have side effect in other scopes). It could go like this:

    $scope.incOther = function(item) {
            for (var i=0; i<$scope.items.length; i++){
                if ($scope.items[i] !== item){
                    $scope.items[i].value++;
                }
            }
        };
    

    The example function would modify values in other scopes and AngularJS – to display correct results – need to evaluate watchers in parent scopes (up to the $rootScope since we don’t know where an object was defined).

    Here is the complete jsFiddle illustrating this: http://jsfiddle.net/pkozlowski_opensource/Z6e5g/3/

    In fact the above jsFiddle also includes an object in a $rootScope to illustrate that the watchers evaluation really needs to start at the very top.

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

Sidebar

Related Questions

I have a click event that happens outside the scope of my custom directive,
The directive's attributes don't change when the scope is updated, they still keep the
I have an AngularJS page with several form inputs. When the some of the
How can I detect onKeyUp in AngularJS? I'm looking for an 'ngOnkeyup' directive, similar
Using AngularJS if I set a simple input text box value to something like
I created a custom directive attribute that will turn an ordinary select box into
I am learning about AngularJS and see it adds some of its own attributes
My AngularJS template contains some custom HTML syntax like: <su-label tooltip={{field.su_documentation}}>{{field.su_name}}</su-label> I created a
In AngularJS these two controller declarations are equivalent: function BlahCtrl($scope, $http) { ... }
I'm seeing some very odd behaviour in my AngularJS app. When a single $broadcast

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.