I have an anonymous function tied to the $scope in AngularJS. Problem is that the function is invoked 2 times and hence the "Hello!" is alerted twice.
I have no explicit watch defined on the function.
I know that this is somehow related to Angular digest cycle, but I am not able to understand how.
angular.module("root", [])
  .controller("index", function($scope) {
    $scope.myObj = {};
    $scope.myObj.text = function() {
      alert("Hello!");
      return "<b>Hello!</b>";
    }
  });
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.1/angular.min.js"></script>
<html>
  <body ng-app="root">
    <p ng-controller="index">
      <span ng-bind-html-unsafe="myObj.text()"></span>
    </p>
  </body>
</html>