angularjs - ng-src 用于本地镜像

标签 angularjs image

我有一个 AngularJS 项目,我正在尝试显示本地文件夹中的图像。 我的文件夹层次结构是这样的:

--app(folder)
-----controllers(folder)
-----services(folder)
-----views(folder)
--------images(folder)
-----------image1.jpg
-----------image2.jpg
-----------image3.jpg
--------persons.html
--------departments.html
--index.html

我在 personsController.js 中有图像地址:

$scope.fooImageAddress='images/image1.jpg';

person.html中:

<img ng-src="{{ fooImageAddress}}" alt="here should be an image"/>

什么也没有显示,只有 alt 消息 if img。 我能做什么?

我已阅读 this问题,thisthis ,并尝试了建议,但没有结果。

最佳答案

您必须更改相对于您的index.html 文件的地址

所以我想app/views/images/image1.jpg

关于angularjs - ng-src 用于本地镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41845879/

相关文章:

javascript - angularjs promise 在显示消息之前等待 3 个服务完成

javascript - 带变量的 ng-模型名称

javascript - 使用 Cordova 在 iOS 中显示带有外部源的图像

angularjs - Angular 2 : Error while creating new component via CLI

html - JPG 欢迎图像不显示在 Rails 应用程序中

javascript - 使用 promise 的 $scope 问题

javascript - jQuery 切换 - 图标切换点击?

java - 如何修改像素并使用鼠标点击 Action ?

objective-c - 将 NSImage 转换为 NSData

html - <img> 定位行为