胸腺价值发送angularJS ng onclick方法
Thymeleaf value send angularJS ng-onclick method
我的问题是thymelaf与angularJS的集成。我有这个thymleaf页面:
<div ng-controller="ctrlsubcomment" >
<div class="media" th:fragment="comments" th:each="newsComment : ${comments}">
<img class="media-object" src="/resources/images/adam1.jpg" alt="" width="52" height="52" />
<div class="media-body">
<div class="media-heading">
<span th:text="${newsComment.comment.user.name}"></span>
<span th:text="${newsComment.comment.user.surname}"></span>
<small>
<span class="glyphicon glyphicon-calendar"></span>
<span th:text="${newsComment.comment.creationTime}"></span>
</small>
</div>
<span th:text="${newsComment.comment.text}"></span>
<img th:if="${newsComment.comment.image != null and newsComment.comment.image.fileExist()}" th:src="${newsComment.comment.image.getImageData()}" alt="" width="160" height="120"/>
</div>
<div class="media-icons" >
<div class="btn-group" role="group" aria-label="...">
<span th:inline="text" th:text="${newsComment.comment.id}">${newsComment.comment.id}</span>
<a href="#" class="btn btn-success btn-xs"><span class="glyphicon glyphicon-thumbs-up"></span> (45)</a>
<a href="#" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-thumbs-down"></span> (12)</a>
<button type="button" ng-click="addSubComment(${newsComment.comment.id})" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#cevapla">
<span class="glyphicon glyphicon-share-alt"></span>
Cevapla
</button>
</div>
</div>
<div class="cevap">
<img class="media-object" src="/images/adam7.jpg" alt="" width="52" height="52" />
<div class="media-body">
<div class="media-heading">Kemal Yapıcı<small> <span class="glyphicon glyphicon-calendar"></span> 04.11.2014 16:30</small></div>
some text.
</div>
</div>
</div>
</div>
</div>
我的AngularJS
方法是:
app.controller('ctrlsubcomment', function($scope, $http) {
$scope.newssubcomment = {
mainComment: { id : ""} ,
comment: {text: ""}
};
$scope.addSubComment = function(commentId) {
$scope.newssubcomment.mainComment.id = commentId;
alert("helllo comment : "+commentId +" " + $scope.newssubcomment.mainComment.id);
};
}
我的代码不起作用。我有AngularJS
语法错误:
"错误:语法错误:令牌"{"是意外的,在表达式[addSubComment([${newsComment.comment.id}])]的第17列,从[{newsComment.id}])]开始,应为[]。
我搜索了所有的互联网,然后找到了解决方案。
th:attr="ng-click='addSubComment('''+${newsComment.comment.id}+''');'"
引用:http://www.mattheye.com/passing-data between-spring-mvc-and-angular js/
相关文章:
- AngularJS:ng之后,重复$scope值未按预期更新
- AngularJS ng开关或类似的动态值工作
- AngularJS ng include dons'不起作用
- AngularJS ng选项在选择一个选项后删除了默认的空白值
- 使用angularjs ng Show/ng hide显示和隐藏不同的内容
- 如何正确应用Angularjs ng repeat
- AngularJS ng include won'不知什么原因不起作用
- AngularJS ng-init does not work
- 自定义指令中的AngularJS ng模型
- AngularJS ng重复处理空列表事例
- AngularJS-ng使用字符串索引在数组上重复
- 如何在AngularJS-ng重复循环中将长JSON路径缩短为变量
- angularjs ng基于点击时的数组值重复过滤器
- angularjs ng点击运行时标记不起作用
- AngularJS ng src不会在$rootScope上使用$watch进行更新
- select中布尔值的Angularjs ng值不起作用
- AngularJS ng下拉树结构的模型定义
- Angularjs:ng重复对象数组
- 使用angularJs ng模式进行10位Regex验证
- AngularJS ng点击在ng重复内更改颜色