我能够从简单的html和javascript获取并显示联系人照片,但是当我使用angularjs模型显示联系人照片时,出现错误。以下是我的源代码:无法通过angularjs在电话中显示联系人照片
名单,我想显示联系人:
<ul class="list">
<li class="item item-thumbnail-left" ng-repeat="contact in contactList">
<img ng-src="{{contact.mphoto}}"/> <!--When I put this path directly (ie "content://com.android.contacts/contacts/30/photo"), I am able to display the image, but when I fetch it from the controller, I am getting error: "unable to read contacts from asset folder" -->
<h2>{{contact.name}}</h2>
<p >{{contact.number}}</p>
</li>
</ul>
这里是我的设置ContactList控制器:
ContactService.find("").then(function(contacts) {
for (var i = 0; i < contacts.length; i++)
{
if (contacts[i].phoneNumbers !== null)
{
for (var j = 0; j < contacts[i].phoneNumbers.length; j++)
{
var img = contacts[i].photos != null ? contacts[i].photos[0].value : "img/default.png";
$scope.contactList.push({name: contacts[i].name.formatted, number: contacts[i].phoneNumbers[j].value, mphoto: img})
}
}
}
你得到的这条底线?我有同样的问题? – user1255162
没有运气,同样的事情在IOS工作,但不是在Android –
@ user1255162请参阅下面的答案也许它也会解决您的问题 –