[英]ng-if inside ng-repeat in angularJS
我根據ng-repeat中的if條件提出一個單獨的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>
存在語法錯誤,您在ng-if中缺少右引號,因此到達下一個html標簽
<div ng-if="widget.Type == 'Bar'">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.