Json angularJS ng重复问题-向$scope添加函数
我使用AJAX从json文件获取数据,将其添加到控制器$scope,然后在ng repeat中使用它。在我尝试向$scope添加一个函数以便它执行另一个功能之前,一切都正常。 工作正常:Json angularJS ng重复问题-向$scope添加函数,json,angularjs,angularjs-ng-repeat,Json,Angularjs,Angularjs Ng Repeat,我使用AJAX从json文件获取数据,将其添加到控制器$scope,然后在ng repeat中使用它。在我尝试向$scope添加一个函数以便它执行另一个功能之前,一切都正常。 工作正常: var myApp = angular.module('CouponsApp',[]); myApp.controller("CouponController",function($scope, $http) { $http.get('CouponsJSON.json').
var myApp = angular.module('CouponsApp',[]);
myApp.controller("CouponController",function($scope, $http) {
$http.get('CouponsJSON.json').
success(function(data, status, headers, config) {
$scope.CouponsList = data;
}).
error(function(data, status, headers, config) {
console.log((data || 'Coupons AJAX Req Failed') + ': ' + status);
});
});
ng repeat停止浏览我的json,并且不再显示在我的html中:
var myApp = angular.module('CouponsApp',[]);
myApp.controller("CouponController",function($scope, $http) {
$http.get('CouponsJSON.json').
success(function(data, status, headers, config) {
$scope.CouponsList = data;
}).
error(function(data, status, headers, config) {
console.log((data || 'Coupons AJAX Req Failed') + ': ' + status);
});
$scope.doStuff()
{
var cellMarkerArray = [];
for(var i=0;i<$scope.CouponsList.CellPhones.length;i++)
{
cellMarkerArray = $scope.CouponsList.CellPhones[i].localVendorAddress;
}
};
});
var myApp=angular.module('CouponsApp',[]);
controller(“CouponController”,函数($scope,$http){
$http.get('CouponsJSON.json')。
成功(函数(数据、状态、标题、配置){
$scope.CouponsList=数据;
}).
错误(函数(数据、状态、标题、配置){
log((数据| |'AJAX请求失败')+':'+状态);
});
$scope.doStuff()
{
var cellmarray=[];
for(var i=0;i$scope.doStuff应该是一个函数
$scope.doStuff = function()
{
var cellMarkerArray = [];
for(var i=0;i<$scope.CouponsList.CellPhones.length;i++)
{
cellMarkerArray = $scope.CouponsList.CellPhones[i].localVendorAddress;
}
};
$scope.doStuff=function()
{
var cellmarray=[];
对于(var i=0;i