angularjs-infdig

Angular 1: ng-repeat throws infdig error

痴心易碎 提交于 2019-12-11 05:39:14
问题 Controller: (function(angular) { var app = angular.module('t2w'); app.factory('httpq', function($http, $q) { return { get: function() { var deferred = $q.defer(); $http.get.apply(null, arguments).success(deferred.resolve).error(deferred.resolve); return deferred.promise; } } }); app.controller('JobsCtrl', ['$scope','httpq','baseUrl', function($scope, httpq, baseUrl) { httpq.get(baseUrl + '/jobs/json').then(function(data) { $scope.jobs = data; }).catch(function(data, status) { console.error(

AngularJS InfDig error (infinite loop) with ng-repeat function that returns array of objects

末鹿安然 提交于 2019-11-29 04:28:10
Here's my code: <h1 ng-repeat="item in func()">something</h1> $scope.func = function(){ return [{"property" : "value1"},{"property": "value2"}]; } In Angular.js v. 1.1.1 there's no mistake. In Angular.JS v 1.2.1 I get an infDig mistake. Fiddle of v.1.1.1 Fiddle of v.1.2.1 Could you explain this situation? Thanks a lot. m59 As of AngularJS 1.2: The "track by" expression was added to ng-repeat and more appropriately addresses this issue as demonstrated in the following code. <h1 ng-repeat="item in func() track by $index">something</h1> $scope.func = function(){ return [{"property" : "value1"},{

AngularJS InfDig error (infinite loop) with ng-repeat function that returns array of objects

天大地大妈咪最大 提交于 2019-11-27 18:40:42
问题 Here's my code: <h1 ng-repeat="item in func()">something</h1> $scope.func = function(){ return [{"property" : "value1"},{"property": "value2"}]; } In Angular.js v. 1.1.1 there's no mistake. In Angular.JS v 1.2.1 I get an infDig mistake. Fiddle of v.1.1.1 Fiddle of v.1.2.1 Could you explain this situation? Thanks a lot. 回答1: As of AngularJS 1.2: The "track by" expression was added to ng-repeat and more appropriately addresses this issue as demonstrated in the following code. <h1 ng-repeat=