javascript - AngularJS 将 {{post.title}} 更改为另一个 HTML 文件

标签 javascript html angularjs

我想更改 HTML 中 {{post.title}} 的值以打开另一个 html 文件。

        <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>

enter image description here

.html 文件的位置:

enter image description here

最佳答案

你可以做到这一点,

 <a  ng-click="redirect()">{{ post.title }} </a>

在 Controller 中:

$scope.redirect = function(){
  window.location = "#/titleDetails.html";
}

关于javascript - AngularJS 将 {{post.title}} 更改为另一个 HTML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42808937/

相关文章:

javascript - 带计时的 jQuery 鼠标悬停

javascript - Ajax 调用不起作用这段代码有什么问题?

html - 如何在haml的脚本标签中使用异步属性?

regex - MVC4 Razr 在 AngularJS 电子邮件正则表达式模式上抛出错误

javascript - AngularJS $routeProvider 问题

javascript - 通过javascript全文搜索CD-Rom上的静态HTML文件

javascript - 如何将元素放在绝对位置的元素下?

html - 是否有针对程序员的HTML教程?

javascript - 当我将属性作为字符串插入时,如何防止 Angular 进行数学运算

javascript - 在 exec 的函数回调中使用 on.exit