zhangxl5232 2019-04-13 12:03 采纳率: 100%
浏览 504
已采纳

angularjs ng=bind-html报错问题

1.angularjs
前台html代码:

js中代码如下:
var app = angular.module('ngappnews', ["businessquery"]);
app.controller("ngControllernews", function ($scope,$sce, $http, businessUtilService, sessions) {
$scope.init = function () {
var data = {
"applySrc": applySrc,
"aac002":$scope.idNumber,
"aac003":$scope.name,
"type":"1"
}
var headers = {
"Authorization": $scope.token
}
businessUtilService.init(data, headers).then(function (response) {
// alert(JSON.stringify(response.data));

        if (response.data == undefined) {
            $scope.isEmpty = true;
        } else {
            if (response.data.length > 0) {

debugger
var dataresult = response.data; //暂定
var maxnum=response.data[0].rowNum; //行号
var array=new Array();
for(var i=0;i // var labelname="ZLCODE"+i;
var ids="ZLTITLE"+i;
array[i]=i;
dataresult[0][ids]=$sce.trustAsHtml(dataresult[0][ids] );
}
$scope.items=dataresult;
$scope.arrays=array; //生成数组
$scope.isEmpty = false;
// $scope.$apply();
} else {
$scope.isEmpty = true;
$(".itemlists").hide();
// $scope.$apply();
}
}
})
}
错误信息:
Error: [$parse:syntax] http://errors.angularjs.org/1.5.8/$parse/syntax?p0=%7B&p1=is%20an%20unexpected%20token&p2=17&p3=items%5B0%5D.ZLTITLE%7B%7B%24index%7D%7D&p4=%7B%7B%24index%7D%7D
at http://localhost:63342/nanning/html/lib/js/angular.min.js:6:412
at s.throwError (http://localhost:63342/nanning/html/lib/js/angular.min.js:230:78)
at s.ast (http://localhost:63342/nanning/html/lib/js/angular.min.js:221:442)
at td.compile (http://localhost:63342/nanning/html/lib/js/angular.min.js:231:329)
at kc.parse (http://localhost:63342/nanning/html/lib/js/angular.min.js:260:95)
at g (http://localhost:63342/nanning/html/lib/js/angular.min.js:125:383)
at Object.compile (http://localhost:63342/nanning/html/lib/js/angular.min.js:274:333)
at oa (http://localhost:63342/nanning/html/lib/js/angular.min.js:71:38)
at s (http://localhost:63342/nanning/html/lib/js/angular.min.js:59:121)
at s (http://localhost:63342/nanning/html/lib/js/angular.min.js:59:253)


OK

说明:后台的数据是通过webservice返回的json串,如果存在多条数据的时候,返回的数据是放到一个大对象里,结构如code0,code1,这种的
麻烦大家帮忙看下。

  • 写回答

2条回答

  • zhangxl5232 2019-04-15 14:10
    关注

    已解决,将转换后的html放到数组中,进行循环

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大