错误:[$ controller:ctrlreg] http://errors.angularjs.org/1.6.4/$controller/ctrlreg?p0=js%2Fapp%2Fshop%2FShopController

时间:2017-06-10 13:52:06

标签: javascript angularjs

我有 Shop.js 脚本:

ActiveSheet.PivotTables("PivotTable19").PivotFields("Caller").AutoSort _
        xlDescending, "C`enter code here`ount of Number", 
          ActiveSheet.PivotTables("PivotTable19"). _
           PivotColumnAxis.PivotLines(1), 1

这是我的html使用Shopcontroller

<pre>(function () {
    'use strict';
    angular
        .module('app')
        .controller('ShopController', ShopController);
    ShopController.$inject = ['$http'];



    function ShopController($http) {
        var vm = this;
        $http.get('/shop/shirts')
            .then(function (response) {
                vm.responsedata = response.product;
            },function (reason) {
                console.log(reason);
            })
            .catch(function (err) {
                console.log(err);
            })
    }


}());

我的route-config文件是

<div class="container">
<div class="row">
    <!--{{# each this}}-->
    <div ng-repeat= "rest in vm.responsedata">
    <div class="col-sm-4">
        <div class="product-image-wrapper">
            <div class="single-products">
                <div class="productinfo text-center">
                    <img src="{{rest.imagePath}}" alt="" />
                    <h2>${{rest.price}}</h2>
                    <p>{{.title}}</p>
                </div>
                <div class="product-overlay" style="background-image: url({{this.imagePath2}});">
                    <div class="overlay-content">
                        <h2>${{this.price}}</h2>
                        <p>{{this.title}}</p>
                        <a href="/details/shirts/{{this.detailLink}}" class="btn btn-default add-to-cart"></i>Show Details</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    <!--{{/each}}-->
</div>

我仍然收到错误:

  

错误:[$控制器:ctrlreg]   http://errors.angularjs.org/1.6.4/ $控制器/ ctrlreg?P0 = JS%2Fapp%2Fshop%2FShopController

2 个答案:

答案 0 :(得分:0)

在route-config文件中将控制器更改为ShopController。

  .when('/shop/shirts', {
                    templateUrl : 'js/app/shop/shop.html',
                    controller : 'ShopController',
                    controllerAs : 'vm'
                });

答案 1 :(得分:0)

你可能搞乱了代码文件中的括号,确保一切正确 下次打开Web浏览器控制台(可能按F12)并查看输出错误