【发布时间】:2014-08-06 10:36:14
【问题描述】:
我目前正在使用 ionic 和 Angularjs 做一个混合移动应用程序,我正在尝试通过 img html 标签显示图像。我的页面由顶部的轮播(效果很好,它显示图像)和带有小图像的列表组成。 在我页面的控制器中有:
app.controller('SalleCtrl', function ($scope,$location) {
$scope.salle = {
"num": "2",
"imgR": [
"img/art_affiche_6_thumb-300x300.jpg",
"img/art_affiche_6_thumb-300x300.jpg"
],
"title": "Salle 2 : Premières peintures",
"_audio_guide": [],
"_audio_guide_fe": [],
"_audio_guide_en": [],
"artworks": [
{
"img": "img/art_affiche_6_thumb-300x300.jpg",
"href": "http://172.16.12.158/wordpress/mcm_oeuvre/oeuvre-14-2/",
"title": "Oeuvre 14"
},
{
"img": "img/art_affiche_9_thumb-300x300.jpg",
"href": "http://172.16.12.158/wordpress/mcm_oeuvre/oeuvre-3/",
"title": "Oeuvre 3"
}
]
};
});
在我的html页面中有:
<ion-view title="{{salle.title}}">
<ion-nav-buttons side="right">
<button menu-toggle="right" class="button button-icon icon ion-navicon"></button>
</ion-nav-buttons>
<ion-content class="has-header" id="" >
<ul rn-carousel class="image">
<li ng-repeat="image in salle.imgR" style="background-image:url({{ image }});background-color:black;background-repeat:no-repeat;background-position:center center;background-size : contain;">
</li>
</ul>
<div class="list">
<a ng-repeat="artwork in salle.artworks" class="item item-avatar" href="{{artwork.href}}">
<img ng-src="{{artwork.img}}">
<h2>{{artwork.title}} {{artwork.img}}</h2>
</a>
</div>
</ion-content>
当我在浏览器上显示它时,一切正常。但是当我在智能手机上试用时,旋转木马可以工作,它会显示图像,但列表不显示图像,而不是 {{artwork.img}} 显示所有图像。 我尝试:
- 将 'ng-src' 替换为 'src' 但没有任何反应
- 将 ng-src="{{artwork.img}}" 替换为 ng-src="img/art_affiche_6_thumb-300x300.jpg" 即可。
显然绑定不正确...你知道为什么吗?以及如何解决?! 此外,在我的智能手机上,图像的路径看起来像“cdvfile://localhost/persistent/...”。旋转木马效果很好,但图像列表不起作用,当我将“cdvfile://localhost/persistent/...”翻译成“file://mnt/sdcard/...”时它可以工作。为什么?!
【问题讨论】:
标签: javascript jquery html angularjs