angular.js - Angular根据JSON数据动态生成在网页上的列表
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-15 16:56:22
0
1
625
[ { "meta": { "author": "test", "date_create": "2015-10-14T00:00:00", "date_modify": "2015-10-14T00:00:00", "filename": "微信页面整合", "git_username": "kk", "subdir": "article", "subtitle": null, "tags": [ "api", "微信", "开发文档" ], "title": "微信页面整合" } }, { "meta": { "author": "Waylan LimbergJohn Doe", "date_create": "2015-10-14T00:00:00", "date_modify": "2015-10-14T00:00:00", "filename": "python2编码问题.md", "git_username": "guyskk", "subdir": "article", "subtitle": null, "tags": [], "title": "python2编码问题" } } ]

json文件格式如上,如何通过angular根据返回的json文件(可能有多个文章数据),动态生成列表。要求能读取到meta和title。。第一次用angular,卡在这种数组套对象,对象里面又是对象的模式了。。。好几天了。

谢谢!

曾经蜡笔没有小新
曾经蜡笔没有小新

Antworte allen (1)
给我你的怀抱

用ng-repeat应该很容易做吧
例子(http://plnkr.co/edit/xsQqAFUiwigPEkbyNtdO)

html

    AngularJS Plunker     

{{ele.meta.author}}

{{ele.meta.title}}


js

var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.name = 'World'; $scope.data = [ { "meta": { "author": "test", "date_create": "2015-10-14T00:00:00", "date_modify": "2015-10-14T00:00:00", "filename": "微信页面整合", "git_username": "kk", "subdir": "article", "subtitle": null, "tags": [ "api", "微信", "开发文档" ], "title": "微信页面整合" } }, { "meta": { "author": "Waylan LimbergJohn Doe", "date_create": "2015-10-14T00:00:00", "date_modify": "2015-10-14T00:00:00", "filename": "python2编码问题.md", "git_username": "guyskk", "subdir": "article", "subtitle": null, "tags": [], "title": "python2编码问题" } } ]; });
    Neueste Downloads
    Mehr>
    Web-Effekte
    Quellcode der Website
    Website-Materialien
    Frontend-Vorlage
    Über uns Haftungsausschluss Sitemap
    Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!