AngularJs: controller is called twice by using $routeProvider

前端 未结 10 2249
慢半拍i
慢半拍i 2020-12-04 14:43

Module routes:

var switchModule = angular.module(\'switchModule\', []);

switchModule.config([\'$routeProvider\', function($routeProvider) {
    $routeProvid         


        
10条回答
  •  我在风中等你
    2020-12-04 14:48

    I had face same issue today. I had added controller name in my $routeProvider and also in my html.

    $routeProvider
        .when('/login', {
                controller: 'LoginController',
                templateUrl: 'html/views/log-in.html'
         })
    

    and in my view as

    You can remove controller name either from your view or from your routeprovider.

提交回复
热议问题