我的网站上有以下代码,我希望在行中显示图像。我已经尝试在变量中使用标记然后回显它,并且还直接回显但是图像总是只显示为文本。有办法解决这个问题吗?
以下代码段显示了我正在尝试实现的内容,其中回显的HTML标记在运行时显示为文本。
注意:由于PHP无法运行,因此下面的代码段会中断,因此它并没有真正显示问题。
function MyCtrl($scope) {
$scope.environment_service_packages =
[
{name: 'Click to expand', info: {text: '<?php
image = "random-image-15.jpg";
$embed = '"<img src=' . '"http://www.spyderonlines.com/image.php?pic=/images/wallpapers/random-image/' . $image . '"' . '>"';
echo "Image:"; echo "$embed";
echo "Above is supposed to look like image at http://www.spyderonlines.com/image.php?pic=/images/wallpapers/random-image/random-image-15.jpg";
?>', show: false}},
{name: 'obj2', info: {text: 'some extra info for obj2', show: false}},
];
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app>
<table ng-controller="MyCtrl" class="table table-hover table-striped">
<tr class="info">
<td>...</td>
</tr>
<tbody ng-repeat="x in environment_service_packages">
<tr ng-click="x.info.show = !x.info.show">
<td> {{ x.name }}
</tr>
<tr ng-show="x.info.show">
<td>
{{ x.info.text }}
</td>
</tr>
</tbody>
</table>
</body>