I have created a controller module in a javascript file,
myController.js
(function () {
"use strict";
var app = angular.module("mymodule");
app.controller("MyController", ["$scope", "service",
function ($scope, service) {
$scope.doSomething = function(){
var element = service.getElement(1);
element.events.register("mouseover", element, function(){});
}
}
]);
)();
I referenced in in the index.html file like following.
<script src="js/lib/myController.js"></script>
And I used state to call my controller template.
app.config(["$stateProvider", function ($stateProvider) {
$stateProvider.state("myctrl", {
url: "/myctrl",
templateUrl: "templates/myctrl/myctrl.html",
controller: "MyController"
});
}])
I am putting a breakpoint to $scope.doSomething function. When I started the application the breakpoint stopped that point. And when I call url of my controller template url, breakpoint is firing again. So my event registered twice, and event firing two times.
I think controller is creating two times or another problem.
Solution: