-1

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?

TheNone
  • 5,684
  • 13
  • 57
  • 98

1 Answers1

2

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?

Andreas Jägle
  • 11,632
  • 3
  • 31
  • 31