My index.php
<!doctype html>
<html lang="en" ng-app="abc">
<head>
    <meta charset="utf-8">
    <title>Google Phone Gallery</title>
    <base href="" />
</head>
<body>
    <div ng-controller="test">
        {{sayhello()}}
    </div>
</body>
<script src="js/core/angular.min.js"></script>
<script src="js/modules/example/controllers/controller.js"></script>
</html>
My controller.js:
var app = angular.module('abc', []);
app.factory('greeter', function($rootScope){
    return{
        greet: function(){
            alert('run');
        }
    }
});
app.controller('test', function($scope, greeter){
    $scope.sayhello = function(){
        greeter.greet();
    }
});
Can you guys tell me, why my alert ran twice?
But if I change:
<div ng-controller="test">
    {{sayhello()}}
</div>
To:
<div ng-controller="test">
    <input type="button" value="Click 2 run" ng-click="sayhello()">
</div>
It runs only once? Can you guys tell me how?
 
     
     
     
    