我根据ng-repeat中的条件呈现一个单独的div。但它会抛出一个错误,说“语法错误:令牌'<'不是表达式[widget.Type =='Bar'>“。的第32列的主要表达式 我该如何解决?
这是我的代码,
HTML:
<div id="main" class="drop-container" ng-click="addEvent($event)" droppable>
<div ng-controller="CustomWidgetCtrl" style="margin: 20px; top: 50px; left: 80px; height: 300px; width: 500px; " ng-repeat="widget in dashboard.widgets" ng-style="{ 'left':widget.sizeX, 'top':widget.sizeY }"
data-identifier="{{widget.id}}">
<div class="box" >
<div class="box-header" >
<h3>{{ widget.name }}</h3>
<div class="box-header-btns pull-right">
<a title="settings" ng-click="openSettings(widget)"><i class="glyphicon glyphicon-cog"></i></a>
<a title="Remove widget" ng-click="remove(widget)"><i class="glyphicon glyphicon-trash"></i></a>
</div>
</div>
<div ng-if="widget.Type == 'Bar'>
<body ng-controller="MainCtrl"> <div data-ac-chart="'Bar'" data-ac-data="data" data-ac-config="config" class="chart">
</div>
</body>
</div>
</div>
</div>
</div>
答案 0 :(得分:2)
存在语法错误,您缺少在ng中关闭双引号 - 如果它正在到达下一个html标记
<div ng-if="widget.Type == 'Bar'">