简体   繁体   English

加载的图像在ios Ionic Framework中不可见

[英]Loaded images aren't visible in ios Ionic Framework

I'm newbie to Ionic Framework, but I have already faced with a problem of images loading. 我是Ionic Framework的新手,但是我已经面临图像加载的问题。

Here is I'm getting an object of images' urls from the server via get response 这是我通过获取响应从服务器获取图像网址的对象

I can see the images' layout via chrome's tool "Check element", but I can't see them at all on the page, they are just not visible. 我可以通过chrome工具“检查元素”查看图片的布局,但在页面上根本看不到它们,只是看不见。

Maybe I need to load them in cache at first and then show them or smth? 也许我首先需要将它们加载到缓存中,然后再显示它们或显示?

So, here is the code: 因此,这是代码:

Here is an app.js file: 这是一个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');

});

That's a controllers.js: 那是一个controllers.js:

angular.module('starter.controllers', [])

.controller('ImagesDashCtrl', function($scope, myImages) {

 $scope.images = [];

 $scope.loadImages = function() {

myImages.getDownloadedImages().then(function(images){
  $scope.images = images;
});
}

});

Here is the services.js: 这是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;
          });

}

} }); }});

And in main.html just a simple ng-repeat from images and so on, also I use "ion-nav-view" in index.html 在main.html中,只是图像的简单ng-repeat等,我也在index.html中使用“ ion-nav-view”

Thank you very much 非常感谢你

First of all: It seems you never execute the $scope.loadImages function. 首先:似乎您从未执行$scope.loadImages函数。

There are 2 ways of referencing the images 有两种参考图像的方法

one way would be to download them manually and put them in an images folder within the ionic app, then you can simply reference to them like in any web application. 一种方法是手动下载它们并将它们放在ionic应用程序中的图像文件夹中,然后您可以像在任何Web应用程序中一样简单地引用它们。 (they are locally then) (然后在本地)

the other one would be you reference them in the internet. 另一个是您在互联网上引用它们。 So you use the absolute url to the images and they are getting downloaded. 因此,您使用图像的绝对URL,然后将其下载。

I would recommend the first way. 我建议第一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM