在ng-src中添加动态范围变量的问题

时间:2015-12-09 14:51:13

标签: angularjs

我希望附加一个动态变量,它是我的主机名映像网址,但我补充说我在控制台中收到错误。我使用下面的代码。 在控制器中。

$scope.host ="localhost:8199/";
<img ng-src="{{group.groupImagePath ?"+host+"group.groupImagePath :    ('img/group.png')}}"/>

我想要主持人

1 个答案:

答案 0 :(得分:1)

如果您保持视图更清洁并且仅在控制器内部构建最终URL,那可能会更好:

$scope.url = $scope.group.groupImagePath ? $scope.host +  $scope.group.groupImagePath : 'img/group.png';

然后在你的视图中,

<img ng-src="{{url}}"/>
相关问题