[英]Loaded images aren't visible in ios Ionic Framework
我是Ionic Framework的新手,但是我已經面臨圖像加載的問題。
這是我通過獲取響應從服務器獲取圖像網址的對象
我可以通過chrome工具“檢查元素”查看圖片的布局,但在頁面上根本看不到它們,只是看不見。
也許我首先需要將它們加載到緩存中,然后再顯示它們或顯示?
因此,這是代碼:
這是一個app.js文件:
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('main', {
url: "/main",
templateUrl: "templates/main.html",
controller: 'ImagesDashCtrl'
});
$urlRouterProvider.otherwise('/main');
});
那是一個controllers.js:
angular.module('starter.controllers', [])
.controller('ImagesDashCtrl', function($scope, myImages) {
$scope.images = [];
$scope.loadImages = function() {
myImages.getDownloadedImages().then(function(images){
$scope.images = images;
});
}
});
這是services.js:
angular.module('starter.services', [])
.factory('myImages', function($http) {
var myDownloadedImages = [];
return {
getDownloadedImages: function() {
return $http.get('http://www.test1.com').then(function(response) {
myDownloadedImages = response.data;
return myDownloadedImages;
});
}
}});
在main.html中,只是圖像的簡單ng-repeat等,我也在index.html中使用“ ion-nav-view”
非常感謝你
首先:似乎您從未執行$scope.loadImages
函數。
有兩種參考圖像的方法
一種方法是手動下載它們並將它們放在ionic應用程序中的圖像文件夾中,然后您可以像在任何Web應用程序中一樣簡單地引用它們。 (然后在本地)
另一個是您在互聯網上引用它們。 因此,您使用圖像的絕對URL,然后將其下載。
我建議第一種方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.