微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – Thymeleaf值发送angularJS ng-onclick方法

我的问题是thymeleaf与angularJS的整合.我有这个thymleaf页面

dam1.jpg" alt="" width="52" height="52" />
heading"> timageData()}" alt="" width="160" height="120"/>

我的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语法错误:

“Error: Syntax Error: Token ‘{‘ is unexpected,expecting []] at column 17 of the expression [addSubComment([${newsComment.comment.id}])] starting at [{newsComment.comment.id}])].

最佳答案
我挖了所有互联网然后找到了解决方案.

th:attr="ng-click='addSubComment(\''+${newsComment.comment.id}+'\');'" 

引用:
http://www.mattheye.com/passing-data-between-spring-mvc-and-angularjs/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐