**我想在html中使用angular **显示种子或“torrents”中存在的任何其他数据
此代码工作正常,但当我尝试显示种子时,它什么也没显示。
HTML CODE
02-28 10:59:49.740 12067-12067/? W/art: Unexpected CPU variant for X86 using defaults: x86_64
02-28 10:59:49.765 12067-12067/? W/System: ClassLoader referenced unknown path: /data/app/com.example.filemanager-1/lib/x86_64
02-28 10:59:49.770 12067-12067/? I/InstantRun: Instant Run Runtime started. Android package is com.example.filemanager, real application class is com.example.filemanager.FileManager.
02-28 10:59:49.797 12067-12074/? E/art: Failed writing handshake bytes (-1 of 14): Broken pipe
02-28 10:59:49.797 12067-12074/? I/art: Debugger is no longer active
02-28 10:59:49.797 12067-12074/? I/art: Starting a blocking GC Instrumentation
02-28 10:59:50.284 12067-12067/? W/System: ClassLoader referenced unknown path: /data/app/com.example.filemanager-1/lib/x86_64
02-28 10:59:50.337 12067-12067/? W/ini.filemanager: type=1400 audit(0.0:27): avc: denied { read } for name="/" dev="rootfs" ino=1 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:rootfs:s0 tclass=dir permissive=0
[ 02-28 10:59:50.356 12067:12067 W/ ]
Process pipe failed
02-28 10:59:50.376 12067-12089/? I/OpenGLRenderer: Initialized EGL, version 1.4
02-28 10:59:50.376 12067-12089/? D/OpenGLRenderer: Swap behavior 1
02-28 10:59:50.390 12067-12089/? E/EGL_emulation: tid 12089: eglSurfaceAttrib(1174): error 0x3009 (EGL_BAD_MATCH)
02-28 10:59:50.390 12067-12089/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x76656d668840, error=EGL_BAD_MATCH
角度代码
<section class="list">
<article ng-repeat="object in yifito">
<a href="{{object.url}}" target="_system" onclick="window.open('{{object.url}}',_system,'location=yes')" class="item">
<img ng-src="{{object.small_cover_image}}">
<h2 class="noWhiteSpace">{{object.title}}</h2>
<p class="noWhiteSpace">{{object.genres}}</p>
<p class="noWhiteSpace">Year {{object.year}} Rating {{object.rating}}</p>
<p class="noWhiteSpace">{{object.movies.seeds}}</p>
</a>
</article>
</section>
[1]:
答案 0 :(得分:0)
只需将代码修改为:
即可访问seeds
<p class="noWhiteSpace">{{object.seeds}}</p>
这是因为对象$scope.yifito
的结构如下:
[
{title: abc,
genere: afsdf,
year: 2016,
rating: 8,
seeds: 234},
{...}
]
答案 1 :(得分:0)
您的seeds
字段位于torrents
内。字段torrents
是一个列表。
因此,要显示torrents
的数据,您必须使用循环。
<article ng-repeat="object in yifito">
<a href="{{object.url}}" target="_system" onclick="window.open('{{object.url}}',_system,'location=yes')" class="item">
<img ng-src="{{object.small_cover_image}}">
<h2 class="noWhiteSpace">{{object.title}}</h2>
<p class="noWhiteSpace">{{object.genres}}</p>
<p class="noWhiteSpace">Year {{object.year}} Rating {{object.rating}}</p>
<div ng-repeat="torrent in object.torrents">
<p class="noWhiteSpace">{{torrent.seeds}}</p>
</div>
</a>
</article>
它会显示电影的每个种子的种子。
答案 2 :(得分:0)
一些观察结果:
seeds
属性位于torrent
数组的对象内。<强>样本强>
var app = angular.module('myApp', []);
app.controller('MyCtrl',function($scope,$http){
$scope.yifito =[];
$http({
method: "GET",
url: "https://yts.ag/api/v2/list_movies.json?limit=50"
})
.then(function(yifitoData){
$scope.yifito = yifitoData.data.data.movies;
console.log($scope.yifito);
})
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="MyCtrl">
<div ng-repeat="object in yifito">
<a href="{{object.url}}" target="_system" onclick="window.open('{{object.url}}',_system,'location=yes')" class="item">
<img ng-src="{{object.small_cover_image}}">
<h2 class="noWhiteSpace">{{object.title}}</h2>
<p class="noWhiteSpace">{{object.genres}}</p>
<p class="noWhiteSpace">Year {{object.year}} Rating {{object.rating}</p>
<div ng-repeat="item in object.torrents">
<p class="noWhiteSpace">{{item.seeds}}</p>
</div>
</a>
</div>
</div>