名为' NewController'的控制器没有注册

时间:2017-07-23 06:33:38

标签: angularjs angularjs-routing


我有两个控制器
NewController:

     var myApp = angular.module('myApp');

    myApp.controller('NewController', ['$scope', '$http', '$location', '$routeParams', function ($scope, $http, $location, $routeParams) {
        console.log('NewController loaded..');
}]);


OldController:

var myApp = angular.module('myApp');

        myApp.controller('OldController', ['$scope', '$http', '$location', '$routeParams', function ($scope, $http, $location, $routeParams) {
            console.log('Old Controller loaded..');
    }]);


App.js

    var myApp = angular.module('myApp',['ngRoute']);

    myApp.config(function($routeProvider,$locationProvider){
        $locationProvider.html5Mode(true);
        $routeProvider
        .when('/products/add-new-product',{
            controller: 'OldController',
            templateUrl: 'views/product/add-new-product.html'
        })
           .when('/merchant/view-posted-products',{
                controller: 'NewController',
                templateUrl: 'views/dashboard/view-posted-products.html'
            })
            .otherwise({
                redirectTo: '/home'
            })
    });


问题是:我所有使用 OldController 的路线都在工作,但对于 NewController 我收到错误,名称为&#的控制器39; NewController'没有注册。
请帮忙..

0 个答案:

没有答案