Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript TypeError:XX不是一个函数_Javascript_Angularjs - Fatal编程技术网

Javascript TypeError:XX不是一个函数

Javascript TypeError:XX不是一个函数,javascript,angularjs,Javascript,Angularjs,我写了下面的代码,但它给出了一个错误。 错误是 angular.js:14525 TypeError: FirstAncientTheatreFactory.getFirstTheatreDetails is not a function services.js .factory('FirstAncientTheatreFactory',function(){ var firstheatrefact = {}; var first_ancie

我写了下面的代码,但它给出了一个错误。

错误是

angular.js:14525 TypeError: FirstAncientTheatreFactory.getFirstTheatreDetails is not a function
services.js

.factory('FirstAncientTheatreFactory',function(){
            var firstheatrefact = {};

            var first_ancient_theatre = [
                {
                    "id":0,
                    "description":"The first excavation research, which identified the first ancient theater, took place in 1910 when the then Archbishop of Antiquities, Ap. Arvanitopoulos, revealed part of his stage. At the beginning of the 20th century, over a monument (which was not visible), a street was built and various buildings (houses, workshops, shops) were built, some of which, with their deep foundations, caused irreparable damage to the monument. Since 1977, a systematic effort has been made for the complete disclosure and promotion of the monument with excavations and expropriations of buildings, which continues, from the EO of Prehistoric and Classical Antiquities",
                    "image":"img/first_ancient_theatre/first_ancient_theatre1.jpg"
                }
            ]

            firstheatrefact.getFirstTheatreDetails = function(index){
                return first_ancient_theatre[index];
            }

            return first_ancient_theatre;
        })
        .factory('feedbackFactory', ['$resource', 'baseURL', function ($resource, baseURL) {

            var feedfac = {};

            feedfac.getFeedback = function () {
                return $resource(baseURL + "feedback/:id", null, {'update': {method: 'PUT'}});
            };

            return feedfac;
    }])
.controller('FirstAncientTheatreController', ['$scope', 'FirstAncientTheatreFactory', function ($scope, FirstAncientTheatreFactory) {

            $scope.message="Loading ...";

            $scope.firstTheatreZero = FirstAncientTheatreFactory.getFirstTheatreDetails(0);



    }])
controller.js

.factory('FirstAncientTheatreFactory',function(){
            var firstheatrefact = {};

            var first_ancient_theatre = [
                {
                    "id":0,
                    "description":"The first excavation research, which identified the first ancient theater, took place in 1910 when the then Archbishop of Antiquities, Ap. Arvanitopoulos, revealed part of his stage. At the beginning of the 20th century, over a monument (which was not visible), a street was built and various buildings (houses, workshops, shops) were built, some of which, with their deep foundations, caused irreparable damage to the monument. Since 1977, a systematic effort has been made for the complete disclosure and promotion of the monument with excavations and expropriations of buildings, which continues, from the EO of Prehistoric and Classical Antiquities",
                    "image":"img/first_ancient_theatre/first_ancient_theatre1.jpg"
                }
            ]

            firstheatrefact.getFirstTheatreDetails = function(index){
                return first_ancient_theatre[index];
            }

            return first_ancient_theatre;
        })
        .factory('feedbackFactory', ['$resource', 'baseURL', function ($resource, baseURL) {

            var feedfac = {};

            feedfac.getFeedback = function () {
                return $resource(baseURL + "feedback/:id", null, {'update': {method: 'PUT'}});
            };

            return feedfac;
    }])
.controller('FirstAncientTheatreController', ['$scope', 'FirstAncientTheatreFactory', function ($scope, FirstAncientTheatreFactory) {

            $scope.message="Loading ...";

            $scope.firstTheatreZero = FirstAncientTheatreFactory.getFirstTheatreDetails(0);



    }])
html页面

<div class="container" ng-contoller="FirstAncientTheatreController">
                <div class="row">
                    <div class="col-xs-12">

                        <p style="font-size:18px;">{{firstTheatreZero.description}}</p>

                    </div>    
                </div>
      </div>

{{{firsttheratezero.description}


在定义函数getFirstCharteredDetails时,我觉得这有点奇怪。我错过什么了吗

您确实
返回了第一个古剧场,,

而你应该先返回
firstheatrefact

你确实
先返回了古剧场,,

而您应该返回
firstheatrefact

您返回的是json变量而不是对象。改变
返回第一个古剧场
to
returnfirstheatrefact

返回的是json变量而不是对象。改变
返回第一个古剧场
to
returnfirstheatrefact

因为您没有使用方法返回对象。。。。您返回arrayChange
返回第一个古剧场
to
returnfirstheatrefact…因为您没有使用方法返回对象。。。。您返回arrayChange
返回第一个古剧场
to
returnfirstheatrefact。。。