如何使用Angularjs在分页内显示JSON数据?

时间:2014-06-11 05:13:23

标签: javascript json angularjs

[
{
    "id": "1",
    "titlu": "client1", 
    "subtitlu": "client1", 
    "continut": "client1 is ...",
    "bigimage": "images/client1.jpg",
    "smallimage1": "images/client1.jpg",
    "smallimage2": "images/client1.jpg",
    "smallimage3": "images/client1.jpg",
    "smallimage4": "images/client1.jpg"
},
{
    "id": "2",
    "titlu": "client2", 
    "subtitlu": "client2", 
    "continut": "client2 is ...",
    "bigimage": "images/client2.jpg",
    "smallimage1": "images/client2.jpg",
    "smallimage2": "images/client2.jpg",
    "smallimage3": "images/client2.jpg",
    "smallimage4": "images/client2.jpg"
},
{
    "id": "3",
    "titlu": "client3", 
    "subtitlu": "client3", 
    "continut": "client3 is ...",
    "bigimage": "images/client3.jpg",
    "smallimage1": "images/client3.jpg",
    "smallimage2": "images/client3.jpg",
    "smallimage3": "images/client3.jpg",
    "smallimage4": "images/client3.jpg"
} 

这是我的client.json,我想一次加载页面,json的每个索引。像PREV按钮之类的东西,并将从我的页面上的json加载以前的id。有人可以给我一个链接或什么来帮助我。

Controller.js

animateApp.controller('projectsController', ['$scope', '$routeParams', '$http',
function($scope, $routeParams, $http){
    $http.get('res/json/client.json').success(function(data){
    $scope.projects = data;
    $scope.currentProject = 1;
});

1 个答案:

答案 0 :(得分:0)

尝试此链接,其中包含数据,您可以将它们与您的控件绑定。

JSON Link

$scope.filteredItems = $filter('filter')($scope.items, function (item) {
    for(var attr in item) {
        if (searchMatch(item[attr], $scope.query))
            return true;
    }
    return false;
});