Search code examples
angularjsng-viewangularjs-ng-route

Using ngView Makes Any Process Twice


When I use ngView and call a controller inside another one, this makes any process twice :

$routeProvider
    .when('/', {
        templateUrl: '/main.html',
        controller: 'main'
    })
    .when('/user', {
        templateUrl: '/user.html',
        controller: 'user'
    })
    });

<body ng-controller="main">
     <div ng-view><!--here is another controller --></div>
</body>

enter image description here enter image description here

When using ngInclude there is not this problem. What is wrong with using ngView?


Solution

  • It looks like if you are using your main controller twice:

    • By referencing it in the template as ng-controller
    • In the routing config of the "/" route

    Probably you want remove the ng-controller from your index page?