angularjs $window.onclick performs better than ng-click2019 Community Moderator ElectionHow do I detect a click outside an element?Trigger a button click with JavaScript on the Enter key in a text boxImprove INSERT-per-second performance of SQLite?Why are elementwise additions much faster in separate loops than in a combined loop?How does data binding work in AngularJS?Why is it faster to process a sorted array than an unsorted array?Is < faster than <=?“Thinking in AngularJS” if I have a jQuery background?AngularJS: Service vs provider vs factoryWhy is printing “B” dramatically slower than printing “#”?
Should QA ask requirements to developers?
Can someone explain what is being said here in color publishing in the American Mathematical Monthly?
How much stiffer are 23c tires over 28c?
Good allowance savings plan?
Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?
Look through the portal of every day
My story is written in English, but is set in my home country. What language should I use for the dialogue?
Do f-stop and exposure time perfectly cancel?
Replacing Windows 7 security updates with anti-virus?
Do items de-spawn in Diablo?
Unreachable code, but reachable with exception
Best approach to update all entries in a list that is paginated?
Is there any way to damage Intellect Devourer(s) when already within a creature's skull?
Grey hair or white hair
How do I express some one as a black person?
Should I take out a loan for a friend to invest on my behalf?
Single word request: Harming the benefactor
Does "variables should live in the smallest scope as possible" include the case "variables should not exist if possible"?
Aliens englobed the Solar System: will we notice?
Why is Beresheet doing a only a one-way trip?
Force user to remove USB token
PTIJ: Why can't I eat anything?
MTG: Can I kill an opponent in response to lethal activated abilities, and not take the damage?
What does a stand alone "T" index value do?
angularjs $window.onclick performs better than ng-click
2019 Community Moderator ElectionHow do I detect a click outside an element?Trigger a button click with JavaScript on the Enter key in a text boxImprove INSERT-per-second performance of SQLite?Why are elementwise additions much faster in separate loops than in a combined loop?How does data binding work in AngularJS?Why is it faster to process a sorted array than an unsorted array?Is < faster than <=?“Thinking in AngularJS” if I have a jQuery background?AngularJS: Service vs provider vs factoryWhy is printing “B” dramatically slower than printing “#”?
I had a scenario where I have to make some alterations in localstorage as well as in some other data of the controller, this logic was supposed to be done on click of anywhere in whole page. This code was supposed to close all colorpickers if click was done anywhere on the body but not on the colorpicker button, but if clicked on colorpicker button then close all others colorpickers and open only the respective one. First I tried using ng-click which was working okay but the pace of closing all colorpickers and opening of respective one was very slow.
Note that I tried using $scope.$apply(); but that didn't work but instead it started giving me error that angularjs digestion is already in progress. Then I used $window.onclick which worked perfectly and the pace of colorpickers closing and opening was also very fine. I am wondering why $window.onclick worked better than ng-click. That function is as follows
$window.onclick = function (e) ;
javascript angularjs performance onclick angularjs-ng-click
add a comment |
I had a scenario where I have to make some alterations in localstorage as well as in some other data of the controller, this logic was supposed to be done on click of anywhere in whole page. This code was supposed to close all colorpickers if click was done anywhere on the body but not on the colorpicker button, but if clicked on colorpicker button then close all others colorpickers and open only the respective one. First I tried using ng-click which was working okay but the pace of closing all colorpickers and opening of respective one was very slow.
Note that I tried using $scope.$apply(); but that didn't work but instead it started giving me error that angularjs digestion is already in progress. Then I used $window.onclick which worked perfectly and the pace of colorpickers closing and opening was also very fine. I am wondering why $window.onclick worked better than ng-click. That function is as follows
$window.onclick = function (e) ;
javascript angularjs performance onclick angularjs-ng-click
add a comment |
I had a scenario where I have to make some alterations in localstorage as well as in some other data of the controller, this logic was supposed to be done on click of anywhere in whole page. This code was supposed to close all colorpickers if click was done anywhere on the body but not on the colorpicker button, but if clicked on colorpicker button then close all others colorpickers and open only the respective one. First I tried using ng-click which was working okay but the pace of closing all colorpickers and opening of respective one was very slow.
Note that I tried using $scope.$apply(); but that didn't work but instead it started giving me error that angularjs digestion is already in progress. Then I used $window.onclick which worked perfectly and the pace of colorpickers closing and opening was also very fine. I am wondering why $window.onclick worked better than ng-click. That function is as follows
$window.onclick = function (e) ;
javascript angularjs performance onclick angularjs-ng-click
I had a scenario where I have to make some alterations in localstorage as well as in some other data of the controller, this logic was supposed to be done on click of anywhere in whole page. This code was supposed to close all colorpickers if click was done anywhere on the body but not on the colorpicker button, but if clicked on colorpicker button then close all others colorpickers and open only the respective one. First I tried using ng-click which was working okay but the pace of closing all colorpickers and opening of respective one was very slow.
Note that I tried using $scope.$apply(); but that didn't work but instead it started giving me error that angularjs digestion is already in progress. Then I used $window.onclick which worked perfectly and the pace of colorpickers closing and opening was also very fine. I am wondering why $window.onclick worked better than ng-click. That function is as follows
$window.onclick = function (e) ;
javascript angularjs performance onclick angularjs-ng-click
javascript angularjs performance onclick angularjs-ng-click
edited Mar 7 at 7:41
Deblaton Jean-Philippe
8,29323758
8,29323758
asked Mar 7 at 7:39
Awais NasirAwais Nasir
357
357
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$window is a reference to the browser's window object. (See here for details: https://docs.angularjs.org/api/ng/service/$window)
ng-click causes a digest cycle through $scope.$apply. (Details here: https://docs.angularjs.org/guide/scope)
Relevant part:
Listener directives, such as ng-click, register a listener with the
DOM. When the DOM listener fires, the directive executes the
associated expression and updates the view using the $apply() method.
Therefore, $window.onclick executes faster, because it doesn't cause a digest cycle.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038435%2fangularjs-window-onclick-performs-better-than-ng-click%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$window is a reference to the browser's window object. (See here for details: https://docs.angularjs.org/api/ng/service/$window)
ng-click causes a digest cycle through $scope.$apply. (Details here: https://docs.angularjs.org/guide/scope)
Relevant part:
Listener directives, such as ng-click, register a listener with the
DOM. When the DOM listener fires, the directive executes the
associated expression and updates the view using the $apply() method.
Therefore, $window.onclick executes faster, because it doesn't cause a digest cycle.
add a comment |
$window is a reference to the browser's window object. (See here for details: https://docs.angularjs.org/api/ng/service/$window)
ng-click causes a digest cycle through $scope.$apply. (Details here: https://docs.angularjs.org/guide/scope)
Relevant part:
Listener directives, such as ng-click, register a listener with the
DOM. When the DOM listener fires, the directive executes the
associated expression and updates the view using the $apply() method.
Therefore, $window.onclick executes faster, because it doesn't cause a digest cycle.
add a comment |
$window is a reference to the browser's window object. (See here for details: https://docs.angularjs.org/api/ng/service/$window)
ng-click causes a digest cycle through $scope.$apply. (Details here: https://docs.angularjs.org/guide/scope)
Relevant part:
Listener directives, such as ng-click, register a listener with the
DOM. When the DOM listener fires, the directive executes the
associated expression and updates the view using the $apply() method.
Therefore, $window.onclick executes faster, because it doesn't cause a digest cycle.
$window is a reference to the browser's window object. (See here for details: https://docs.angularjs.org/api/ng/service/$window)
ng-click causes a digest cycle through $scope.$apply. (Details here: https://docs.angularjs.org/guide/scope)
Relevant part:
Listener directives, such as ng-click, register a listener with the
DOM. When the DOM listener fires, the directive executes the
associated expression and updates the view using the $apply() method.
Therefore, $window.onclick executes faster, because it doesn't cause a digest cycle.
answered Mar 7 at 23:50
Florian LimFlorian Lim
5,02722226
5,02722226
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55038435%2fangularjs-window-onclick-performs-better-than-ng-click%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown