{"action":"created","issue":{"url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/309","repository_url":"https://api.github.com/repos/daniel-nagy/md-data-table","labels_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/309/labels{/name}","comments_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/309/comments","events_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/309/events","html_url":"https://github.com/daniel-nagy/md-data-table/issues/309","id":138818407,"number":309,"title":"md-on-deselect and md-on-select called multiple times","user":{"login":"apat183","id":7892604,"avatar_url":"https://avatars.githubusercontent.com/u/7892604?v=3","gravatar_id":"","url":"https://api.github.com/users/apat183","html_url":"https://github.com/apat183","followers_url":"https://api.github.com/users/apat183/followers","following_url":"https://api.github.com/users/apat183/following{/other_user}","gists_url":"https://api.github.com/users/apat183/gists{/gist_id}","starred_url":"https://api.github.com/users/apat183/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apat183/subscriptions","organizations_url":"https://api.github.com/users/apat183/orgs","repos_url":"https://api.github.com/users/apat183/repos","events_url":"https://api.github.com/users/apat183/events{/privacy}","received_events_url":"https://api.github.com/users/apat183/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-06T18:11:47Z","updated_at":"2016-03-06T18:51:13Z","closed_at":null,"body":"When clicking the select all checkbox, the md-on-select function is called for every row in the table. Should the behaviour be just once? The reason being for my example, I trigger and graph update based on selected items. So each time a user selects an item it updates the graph, but when you select all it gets triggered multiple times, there are some promises that a used to get relevant data for the graphs and it causes double counting on some items. \r\n\r\nI noticed that a simple  $watchCollection could be used and that only gets triggered once for when an item is selected and deselected or when you select all or deselect. \r\n```\r\n$scope.$watchCollection('selectedItems', function (newNames, oldNames) {\r\n      console.log('items selected');\r\n    });\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/comments/192962060","html_url":"https://github.com/daniel-nagy/md-data-table/issues/309#issuecomment-192962060","issue_url":"https://api.github.com/repos/daniel-nagy/md-data-table/issues/309","id":192962060,"user":{"login":"daniel-nagy","id":1622446,"avatar_url":"https://avatars.githubusercontent.com/u/1622446?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-nagy","html_url":"https://github.com/daniel-nagy","followers_url":"https://api.github.com/users/daniel-nagy/followers","following_url":"https://api.github.com/users/daniel-nagy/following{/other_user}","gists_url":"https://api.github.com/users/daniel-nagy/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-nagy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-nagy/subscriptions","organizations_url":"https://api.github.com/users/daniel-nagy/orgs","repos_url":"https://api.github.com/users/daniel-nagy/repos","events_url":"https://api.github.com/users/daniel-nagy/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-nagy/received_events","type":"User","site_admin":false},"created_at":"2016-03-06T18:51:13Z","updated_at":"2016-03-06T18:51:13Z","body":"When you select all items, every item that is not already selected or disabled will be selected. Therefore `md-on-select` will be called for every item that is not already selected or is disabled. I think this is the expected behavior for most people. If you are \"doubt counting\" items, that seems like a fault in your logic because `md-on-select` should never be called for an item that is already selected.\r\n\r\nIf you just want to know when there is a change in selected items then `$watchCollection` could work."}}