2015-04-02 56 views
0

出現兩次使用UI-Grid的cellTemplate在選擇這樣的:AngularJS - UI網格CellTemplate按鈕滾動

field: 'isHflrReplaceable', displayName: 'Lead Replacement', width: 200, enableSorting: false, cellTemplate: hflrTemplate 

模板看起來是這樣的:

var hflrTemplate = '<div class="ui-grid-cell-contents">' 
         + '<span class="hflr" ng-show="(row.entity.creditStatus == \'Credit Accepted\') || (row.entity.creditStatus == \'Credit Rejected\')">{{row.entity.creditStatus}}</span>' //IF status = Credit accepted or Rejected 
         + '<span class="hflr" ng-show="(row.entity.creditStatus == \'Credit Pending\') && (row.entity.isHflrReplaceable == 1)"><button ng-if="row.entity.isHflrReplaceable == 1" ng-click="grid.appScope.setSelected(row.entity);" type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target="#HFLRModal"><span class="fa fa-reply m-r-xs"></span>View/Edit</button></span>' //IF status = Credit Pending && can return 
         + '<span class="hflr" ng-show="(row.entity.creditStatus == null) && (row.entity.isHflrReplaceable == 1)"><button ng-if="row.entity.isHflrReplaceable == 1" ng-click="grid.appScope.setSelected(row.entity);" type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#HFLRModal"><span class="fa fa-reply m-r-xs"></span>Request Replacement</button></span>' //IF status = null && can return 
         + '</div>'; 

正確的項目顯示爲預期。這個清單有點長〜200行左右。

當我向上滾動一些長度通過視口,然後備份時,只包含文本的模板跨度很好。但是,模板跨度顯示按鈕具有相同按鈕的附加副本。事實上,隨着我滾動離開按鈕,然後回到按鈕,按鈕不斷添加。我檢查了DOM,每次滾動到按鈕時,都會有一個額外的按鈕。到底他媽發生了什麼?

注意:我不操縱任何數據,我只是用滾動條滾動表格視圖。

回答

0

沒關係。虛驚。

看起來像某人在按鈕本身中添加了ng-if。我不知道爲什麼。並從按鈕標籤本身中刪除,解決了問題。