我想更改 HTML 中 {{post.title}}
的值以超链接 URL。
可能吗?
<div ng-repeat="post in posts">
<h2>
{{post.title}}
<a ng-click="editPost(post._id)" class="pull-right"><span class="glyphicon glyphicon-pencil"></span></a>
<a ng-click="deletePost(post._id)" class="pull-right"><span class = "glyphicon glyphicon-remove"></span></a>
</h2>
<em>{{post.posted}}</em>
<p>{{post.body}}</p>
</div>
最佳答案
假设 post 变量已定义 url 您的 h1 元素数据将如下所示。
<a ng-href="{{post.url}}">{{post.title}}</a>
关于javascript - AngularJS 将 {{post.title}} 更改为超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42808638/