javascript - AugularJS通过服务器请求图片时总是报错 [$interpolate:noconcat]
天蓬老师
天蓬老师 2017-04-11 09:56:16
[JavaScript讨论组]

图片是通过服务器请求得到的,PHP测试正确,页面也是通过服务器端打开的,同样请求的其他数据文字之类的没有错误,可以正常显示,就只是图片出错,当单独测试的时候会出现图片详情,代码截图如下:

当代码是如下情况的时候,就会报错:

当注释掉img所在行的时候,其他数据正常显示

报错浏览器控制台错误代码如下:
angular.js:12314 Error: [$interpolate:noconcat] Error while interpolating: img/{{dish.img_sm}}
Strict Contextual Escaping disallows interpolations that concatenate multiple expressions when a trusted value is required. See http://docs.angularjs.org/api...$sce
http://errors.angularjs.org/1...$interpolate/noconcat?p0=img%2F%7B%7Bdish.img_sm%7D%7D

at http://127.0.0.1/12-1AngularJS_project/js/angular.js:68:12
at Function.$interpolateMinErr.throwNoconcat (http://127.0.0.1/12-1AngularJS_project/js/angular.js:10572:9)
at $interpolate (http://127.0.0.1/12-1AngularJS_project/js/angular.js:10824:30)
at addAttrInterpolateDirective (http://127.0.0.1/12-1AngularJS_project/js/angular.js:8483:27)
at collectDirectives (http://127.0.0.1/12-1AngularJS_project/js/angular.js:7621:13)
at compileNodes (http://127.0.0.1/12-1AngularJS_project/js/angular.js:7448:22)
at compileNodes (http://127.0.0.1/12-1AngularJS_project/js/angular.js:7464:15)
at compileNodes (http://127.0.0.1/12-1AngularJS_project/js/angular.js:7464:15)
at compileNodes (http://127.0.0.1/12-1AngularJS_project/js/angular.js:7464:15)
at compileNodes (http://127.0.0.1/12-1AngularJS_project/js/angular.js:7464:15) <p ng-view="" class="ng-scope">
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

全部回复(3)
阿神

这个是插值出现了连接错误,你试下<img ng-src="{{'img/' + dish.img_sm}}">,这样就可以了。

大家讲道理

你审查一下图片的路径看看是否正确

阿神

<img ng-src="'img/' + {dish.img_sm}">

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号