I am facing an issue with the filter in AngularJS. I am trying to display data where the condition is ordering=1 (a field in my file), but unfortunately, my code is not working.
Below is my code:
<script>
function DanhMucController($scope, $http) {
var url = "data/cate.txt";
$http.get(url).success(function(response) {
$scope.DanhMucList = response;
});
}
</script>
Here is my HTML file:
<div ng-app="" ng-controller="DanhMucController">
<ul class="list-unstyled">
<li ng-repeat="danhmuc in DanhMucList | limitTo:12">
<a href="#">{{danhmuc.career_name }}</a>
</li>
</ul>
</div>
And here is my data file:
[
{
"career_id": "1",
"career_name": "Cate1",
"depended": "0",
"ordering": "1"
},
{
"career_id": "2",
"career_name": "Cate2",
"depended": "0",
"ordering": "1"
},
{
"career_id": "3",
"career_name": "Cate3",
"depended": "0",
"ordering": "2"
}
]
The "limitTo" only retrieves the first 12 elements. I want to specify a particular number like in SQL: select * from table1 where ordering=1 Thank you for your assistance.