绝对URL正在弄乱ng-src

时间:2013-07-12 12:59:21

标签: angularjs

所以,我已经使用了ng-src指令但从未使用绝对图像URL。既然我,我有问题。似乎Angular试图将URL评估为对我没有任何意义的表达式。

这是标签:

<img ng-src="{{message.logo_url}}" ng-show="{{message.logo_url}}">

以下是错误消息:

Error: Syntax Error: Token ':' is an unexpected token at column 5 of the expression [http://m.c.lnkd.licdn.com/mpr/mpr/p/2/000/0ad/2dd/0511c49.png] starting at [://m.c.lnkd.licdn.com/mpr/mpr/p/2/000/0ad/2dd/0511c49.png].
    at Error (<anonymous>)
    at throwError (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:6671:11)
    at parser (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:6663:5)
    at http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:7281:29
    at compileToFn (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:9214:16)
    at Object.Scope.$watch (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:8546:19)
    at http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:15580:11
    at nodeLinkFn (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:4959:13)
    at compositeLinkFn (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:4550:15)
    at compositeLinkFn (http://localhost:8080/customer/service/gui/app/bower_components/angular/angular.js:4553:13) <img ng-src="{{message.logo_url}}" ng-show="{{message.logo_url}}"> angular.js:6349
(anonymous function) angular.js:6349
(anonymous function) angular.js:5420
nodeLinkFn angular.js:4962
compositeLinkFn angular.js:4550
compositeLinkFn angular.js:4553
compositeLinkFn angular.js:4553
publicLinkFn angular.js:4455
ngRepeatAction angular.js:15462
$watchCollectionAction angular.js:8717
Scope.$digest angular.js:8811
Scope.$apply angular.js:9012
done angular.js:10265
completeRequest angular.js:10449
xhr.onreadystatechange angular.js:10404

如果您还需要更多信息,请与我们联系。

1 个答案:

答案 0 :(得分:3)

请改用:

<img ng-src="{{message.logo_url}}" ng-show="message.logo_url">

ngShow的文档中所述。