为什么我的图像根没有找到

时间:2016-04-23 06:22:48

标签: angularjs go

我正在使用带角度的go-lang来构建这种方法的汽车视图: 这是我的main.go

router.GET("/shopping", carBaseController.CarsViewIndex)
router.GET("/images", galleryBaseController.GetImages)

在我的控制器\ cars.go

    func (controller CarController) CarsViewIndex(c *gin.Context) {
        c.HTML(http.StatusOK, "carview.html", gin.H{
            "title": "Car Page"})
    }

func (controller GalleryController) GetImages(c *gin.Context)  {
    imageList := controller.galleryService.FindImages(&bson.M{})
    c.JSON(http.StatusOK, &imageList)
    fmt.Println(imageList)
}

在我的carview.html

                                    <div class="row mix-grid" ng-init="GetAllImages()" >
                                    <div class="col-md-3 mix photography" ng-repeat="image in allimages">
                                        <div class="hover-effect"  >
                                            <div class="img" ><img  src="imagesT/gallery/Thumb/{{image.imagename}}" alt=""
                                                                  class="img-responsive"/></div>
                                            <div class="info"><h3>Manage Images</h3><a href="#"
                                                                                               class="mix-link"><i
                                                    class="glyphicon glyphicon-link"></i></a><a
                                                    href="imagesT/gallery/{{image.imagename}}" data-lightbox="image-1"
                                                    data-title="Image 1" class="mix-zoom"><i
                                                    class="glyphicon glyphicon-search"></i></a></div>
                                        </div>
                                        this is the site fo cars
                                        <a class="btn btn-default" href="carinfo">Learn More
                                            <span class="glyphicon glyphicon-chevron-right"></span></a>
                                    </div>

                                </div>

当我输入http://localhost:3030/shopping时,每件事情都正常但我发现了这个错误

    "NetworkError: 404 Not Found -
http://localhost:3030/imagesT/gallery/Thumb/%7B%7Bimage.imagename%7D%7D"

我不知道为什么这个错误发生在每件事情都运转良好的时候,这就是我用冷杉来说:

<img class="img-responsive" alt="" src="imagesT/gallery/Thumb/2016-chevrolet-cruze-spied-completely-uncovered-news-car-and-driver-photo-658949-s-217x132.jpg">

2 个答案:

答案 0 :(得分:0)

您是否尝试使用ng-src代替src

答案 1 :(得分:0)

如果您在 img 标记中使用 ng-src 而不是 src ,则可以解决此问题。

  

在src属性中使用{{hash}}之类的Angular标记不起作用   右:浏览器将使用文字文本从URL中获取   {{hash}}直到Angular替换{{hash}}中的表达式。该   ngSrc指令解决了这个问题。

查看文档here