2016-11-24 62 views
1

我在角只是新和我使用angularstrap和使用NG-重複

這裏是我的角碼

let alertExcpetion = $alert({ 
    placement: 'top-right', 
    type: 'warning', 
    show: true, 
    keyboard: true 
    template: 'alert.template.html' 
}); 

,這裏是警戒重複的對象數據製作定製報警.template.html

<div class="alert" ng-class="[type ? 'alert-' + type : null]"> 
     <button type="button" class="close" ng-if="dismissable" ng-click="$hide()">&times;</button> 
     <div class="title"> 
      {{ someScopeTitle }} 
     </div> 
     <div> 
      <table class="table table-alert"> 
       <tbody> 
        <tr ng-repeat="student in students"> 
         <td>{{ student.id }}</td> 
         <td><a href="#" ng-click="myfunction(student.someObject)">View File</a> {{student.fullname}}</td> 
        </tr> 
       </tbody> 
      </table> 
     </div> 
    </div> 

加載後.alert爲空,因爲它沒有讀取範圍。有沒有任何可能的方式將範圍傳遞給angularstrap的$ alert?

角帶版本v2.1.6 - 2015年1月11日

回答

2

scope添加到您的警報呼叫。

JS

let alertExcpetion = $alert({ 
    placement: 'top-right', 
    type: 'warning', 
    show: true, 
    keyboard: true 
    template: 'alert.template.html', 
    scope:$scope 
}); 
+0

已經試過了,只是從我的IDE中得到錯誤,說'範圍'不存在於'IAlertOptions''類型中。 – Liky

+0

@Liky您能否創建一個plunker示例? – Muhsin

+0

我只是使用過時的角度帶,這就是爲什麼我有一個錯誤。使用你的代碼,它的工作。謝謝! – Liky

0

按照docs,你可以通過controllercontrollerAs選項警報模式。

another.controller.js

let alertExcpetion = $alert({ 
    placement: 'top-right', 
    type: 'warning', 
    show: true, 
    keyboard: true 
    template: 'alert.template.html', 
    controller: 'ModalController', 
    controllerAs: 'ctrl' 
}); 

modal.controller.js

.controller('ModalController',... 

    $scope.someScopeTitle = 'title'; 

... 

alert.template.html

... 
<div class="title"> 
    {{ ctrl.someScopeTitle }} 
</div> 
... 
+0

我得到誤差與控制器,順便說一句我使用角條帶版本v2.1.6。是因爲它沒有在我的版本中顯示? – Liky

相關問題