gpt4 book ai didi

javascript - 图像未从我的 json 文件加载

转载 作者:行者123 更新时间:2023-12-03 09:32:06 24 4
gpt4 key购买 nike

我正在尝试将 json 文件中的图像加载到我的应用程序中。这是一支代码笔:http://codepen.io/beefman/pen/QbBdVw

这是我的代码:

js:

.controller('photoCtrl', function($scope, $ionicModal, $ionicBackdrop, $ionicScrollDelegate, $ionicSlideBoxDelegate, $http) {
$scope.images = [];

$scope.getImages = function() {
$http.get('https://api.myjson.com/bins/37ia6')
.success(function(data) {
$scope.images = data.images;
})
}

html:

<ion-view view-title="Gallery" align-title="center" ng-controller="photoCtrl" >

<ion-content ng-init="getImages()" class="center" class="has-header padding">

<!-- start Under6/7/8/9s Photos -->
<div class="item item-divider">
<i class="ion-images"></i> Under6/7/8/9s Photos
</div>
<a class="item item-list-detail">
<ion-scroll direction="x">
<img on-hold="onHold()" ng-repeat="image in images" ng-src="{{images.src}}" ng-click="showImages($index)" class="image-list-thumb" />
</ion-scroll>
</a>
</ion-content>
</ion-view>

最佳答案

您的代码中缺少括号和分号。

使用编码环境来检查语法,或实现 JSHint,这是一个检查代码的工具。

http://codepen.io/anon/pen/bdjXYE

angular.module('ionicApp', ['ionic'])

.config(function($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom');
$ionicConfigProvider.navBar.alignTitle('center');

$stateProvider

.state('tabs', {
url: "/tabs",
abstract: true,
templateUrl: "tabs.html"
})

.state('tabs.announcement', {
url: '/announcement',
views: {
home: {
templateUrl: 'announcement.html',
controller: 'photoCtrl'
}
}
})

$urlRouterProvider.otherwise('/tabs/announcement');

})

.controller("photoCtrl", function($scope, $http) {

$scope.data = [];

// $scope.getImages = function() {
console.log("trying to load JSON");
$http.get('https://api.myjson.com/bins/1jovy')
.success(function(data) {
$scope.data = data;
console.log(data);
})
.error(function(error) {
console.log(error)
});
});

关于javascript - 图像未从我的 json 文件加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31471630/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com