Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用ng src how to display image无法加载JSON文件中的AngularJS图像_Html_Angularjs_Json - Fatal编程技术网

Html 使用ng src how to display image无法加载JSON文件中的AngularJS图像

Html 使用ng src how to display image无法加载JSON文件中的AngularJS图像,html,angularjs,json,Html,Angularjs,Json,我使用AngularJS从JSON文件读取图像数据,该文件适用于除图像以外的其他数据。 ng src没有获取任何图像? 我需要将所有图像加载到div中,并使用ng repeat填充我读入的图像数据的src、alt和title属性,但是它不起作用。发生了什么事 那么,我不确定代码的设置方式是否有效 这是我的密码- <!DOCTYPE html> <html ng-app="store"> <head> <link rel="s

我使用AngularJS从JSON文件读取图像数据,该文件适用于除图像以外的其他数据。 ng src没有获取任何图像?

我需要将所有图像加载到div中,并使用ng repeat填充我读入的图像数据的src、alt和title属性,但是它不起作用。发生了什么事

那么,我不确定代码的设置方式是否有效

这是我的密码-

   <!DOCTYPE html>
    <html ng-app="store">
    <head>
    <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
    </head>

    <body ng-controller = "storeController">
    <script type="text/javascript" src="angular.min.js"></script>
    <script type="text/javascript" src="app.js"></script>

        <!--<button class="btn btn-primary" ng-click="showMessage = !showMessage">Toggle Message</button>
        <h2 ng-show="showMessage == true">Secret Message</h2>
        <input type="text" placeholder="Leave a Message" ng-model="message">
        <h2>{{ message }}</h2>-->

        <div class="navbar navbar-default">
            <div class="container-fluid">
                <div class="navbar-header">
                <a class="navbar-brand" href="#">ngPlaces</a>
                </div>
            </div>
        </div>

        <div class="container">
            <div class="col-sm-4" ng-repeat = "place in places">
                <div class="thumbnail">
              <img ng-src="images/{{cribs.image}}.jpg" alt="">
                    <div class="caption">   
                        <h3>{{place.address}}</h3>
                        <p><strong>Type:</strong>{{place.type}}</p>
                        <p><strong>Description:</strong>{{place.description}}</p>
                        <p><strong>Price:</strong>{{place.price | currency}}</p>
                    </div>
                </div>
            </div> 
        </div>
        </body>
    </html>    
app.js

(function(){

var app = angular.module('store', []);
    app.controller('storeController', function($scope, placesFactory){
        $scope.places;

        placesFactory.getPlaces().then(function(response){
           $scope.places = response.data; 
        });

        $scope.sayHello = function(){
            console.log("Hello");
        }
    });

        app.factory('placesFactory', function($http){

            function getPlaces(){
                return $http.get('data.json');
            }

            return {
                getPlaces: getPlaces
            }
        });    
    })();    
改变

来自

  <img ng-src="images/{{cribs.image}}.jpg" alt="">

  <img ng-src="images/{{place.image}}.jpg" alt="">

更改

来自

  <img ng-src="images/{{cribs.image}}.jpg" alt="">

  <img ng-src="images/{{place.image}}.jpg" alt="">


image-link中断控制台输出:crib-6.jpg.jpg加载资源失败:服务器以404(未找到)状态响应。检查指定路径中是否有这些图像在{{place.image}之后删除last.jpg时实际将其删除它正在读取crib-1.jpg.jpg Thank@Saheetharanimage链接中断控制台输出:crib-6.jpg.jpg未能加载资源:服务器以404(未找到)状态响应检查您是否在指定的路径中有这些图像在{place.image}之后删除last.jpg时,实际将其删除它读的是crib-1.jpg.jpg谢谢@saheetharan你试过查看源代码/网络选项卡上的chrome调试器了吗。你应该知道为什么图片没有加载,比如你的网站没有按照它应该的方式构建url。查看“网络”选项卡,您应该会看到404。您是否尝试过查看“源代码/网络”选项卡上的chrome调试器。你应该知道为什么图片没有加载,比如你的网站没有按照它应该的方式构建url。检查网络选项卡,您应该可以看到404。