I have a scoped function that fires more times than is invoked and can't figure out why. I've created a small example in plunker and snippets appear below. when the page is loaded you would think that $scope.hex_color should fire three times but if you view the console in the debugger (Chrome F12) it fires nine times.
Can anyone explain?
http://plnkr.co/edit/7DMwA2InP0v6sD2s5WxW?p=preview
html snippet:
<div ng-repeat="shape in list">
<div>{{ shape.Title }} | {{ hex_color(shape) }}</div>
</div>
controller snippet:
$scope.list = [
{ "Id": 1000, "Title": "Red Ball", "red": "ff", "green": "00", "blue": "00" },
{ "Id": 1001, "Title": "Green Triangle", "red": "00", "green": "ff", "blue": "00" },
{ "Id": 1002, "Title": "Blue Square", "red": "00", "green": "00", "blue": "ff" },
];
$scope.hex_color = function (shape) {
$log.info("hex_color: " + shape.Id);
return "#" + shape.red + shape.green + shape.blue;
}
Update: If I run the code in a local server (the above example was monitoring the code in plunker), it fires 15 times!