Controller function with funny behavior


I need someone’s help to take a look at my project. I couldn’t find the source of the problem.

I have a private function name trigger in my SearchCtrl controller

    var trigger = new function(){
        alert('Alert Me!');

The problem is, the function fires even though it was not called.

The only thing I did was defining the SearchCtrl in the $stateprovider

.state('', {
    url: "/search",
    views: {
        'menuContent': {
            templateUrl: "app/search/search.html",
            controller: 'SearchCtrl'

You can clone and take a look at my full project here:

Thank you.

It’s ok guys. I just solved it myself by referring to here.

A different way of creating controllers compared to ionic templates.