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变量而不是对象。改变
返回第一个古剧场
toreturnfirstheatrefact代码>返回的是json变量而不是对象。改变
返回第一个古剧场
toreturnfirstheatrefact代码>因为您没有使用方法返回对象。。。。您返回arrayChange返回第一个古剧场
toreturnfirstheatrefact代码>…因为您没有使用方法返回对象。。。。您返回arrayChange返回第一个古剧场
toreturnfirstheatrefact代码>。。。