Angularjs Ng-repeat Is Not Showing Table Data
my controller bring data from spring app data but it does not get displayed in form. When I put constants in data it works perfectly fine. here is my code in JS controller sampleAp
Solution 1:
You can't specify $scope in the view, since it's not defined:
<tr ng-repeat="course in $scope.courses">
Becomes
<tr ng-repeat="course in courses">
Solution 2:
As well as omitting the $scope from $scope.courses inside the ng-repeat, you may want to use a $scope.$apply() inside your $http.get success callback to update the scope. This will update the view to the updated $scope.courses binding after a asynchronous process.
Example:
$http.get(actionUrl+"?title="+escape(textToSearch))
.success(function(data, status, headers, config) {
$scope.courses = data;
$scope.$apply(); // used $scope.$apply() to update the scope.
console.log($scope.courses);
})
.error(
function(data, status, headers, config) {
});
});
Solution 3:
Calling search function on ng-change like following
<inputclass="form-control"type="text" placeholder="Title"id="txtTitle" ng-change="search()" ng-model="txtToSearch">
solved the issue. but I am still trying to find out why it isn't working on search button. change search controller as well and here is code
functionSearchCtrl($scope, $http, $location, CS) {
$scope.search = function() {
$scope.result = null;
$http({method: 'GET', url: '/search?title=' + $scope.txtToSearch }).
success(function(data, status, headers, config) {
$scope.results = data;
}).
error(function(data, status, headers, config) {
$scope.status = status;
});
};
$scope.edit=function(c)
{
CourseService.set(course);
$location.path('/edit');
}
}
Post a Comment for "Angularjs Ng-repeat Is Not Showing Table Data"