This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.3k
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ng-repeat does not update after data changing #12589
Copy link
Copy link
Closed
Description
The strange issue take a few days to sovle it, but it seems like a bug. Solution was just change version from "~1.4.3" to "1.3.9" and everything works as expected.
Issue: when new data added the old one not disappear in view, but batarang shows me, that scopes replaced by new one.
search.html ...
<ion-view view-title="Search">
<ion-content
start-y="0"
padding="false"
has-tabs="true"
has-header="true"
>
//I'm using ui-router, so my controller defined inside routes file and it wrap whole search.html file, but to be simple I use it here.
<div ng-controller="SearchCtrl">
<div id="search-box" class="bar bar-header item-input-inset">
<div class="item-input-wrapper">
<i class="icon ion-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="data.sQuery" ng-change="search(data.sQuery)">
</div>
<button ng-click="clearSearch()" class="button button-clear">
Cancel
</button>
</div>
<ul class="list">
<li class="item" ng-repeat="thing in searchResult">{{thing.title}}</li>
</ul>
</div>
</ion-content>
</ion-view>
controller.js ...
.controller('SearchCtrl', function($scope, FactoryData){
$scope.data = {};
$scope.search = ionic.debounce(function() {
//.find() resource method like .query()
FactoryData.search().find({query: $scope.data.sQuery}, function(res) {
$scope.searchResult = res; //return promise
console.log($scope.searchResult);
});
}, 500);
$scope.clearSearch = function() {
$scope.data.sQuery = '';
};
});
service.js ...
.factory('FactoryData', function($resource) {
return {
search: function() {
return $resource( '/api/things?search=:query',
null,
{
'find' : {
method: 'GET',
isArray: true,
cache: false
}
}
);
}
};
things.js ...
//express router
router.route('/things').get(function (req, res) {
var regex = new RegExp(req.query.search, 'i');
Thing.find({title: regex}, function(err, things) {
if (err) {
return res.send(err);
}
res.json(things);
});
});
// so when I use Postman with 'http://localhost:8001/api/things?search=sometitle' such request, everything works as expected, this is not serverside problem
Tell me please what i did wrong. Or this is just a bug?
yah, and also i have had this error, which didn't break nothing, but with 1.3.9 it disappear
TypeError: Cannot read property '' of undefined
at lookup (angular-animate.js:617)
at animationRunner (angular-animate.js:681)
at performAnimation (angular-animate.js:1284)
at angular-animate.js:1217
at angular-animate.js:539
at Scope.$get.Scope.$digest (angular.js:15606)
at Scope.ng.config.$provide.decorator.$delegate.__proto__.$digest (<anonymous>:844:31)
at Scope.$get.Scope.$apply (angular.js:15824)
at Scope.ng.config.$provide.decorator.$delegate.__proto__.$apply (<anonymous>:855:30)
at HTMLInputElement.<anonymous> (angular.js:25180)
Thanks!
Metadata
Metadata
Assignees
Labels
No labels