2015-08-28 105 views
0

對於我的應用程序,(我正在使用角流星/ urigo在Meteor中編寫)我有一個按鈕,單擊時出現一個模型。Bootstrap Angular Modal問題

代碼:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> 
    <div class="modal-dialog" role="document"> 
     <div class="modal-content"> 

      <div class="modal-body" ng-controller="formCtrl"> 
      <div ng-repeat="item in meal.items"> 
       <label>Item {{$index+1}} : 
        <input type="text" class="item" ng-model="item.name"><br> 
       </label> 
       <label>Calories : 
        <input type="number" class="calories" ng-model="item.cal"> 
       </label> 
       <br> 
      </div> 
      </div> 

      <div class="modal-footer"> 
       <button ng-click="addItem()" type="button" class="btn btn-primary">+Item</button> 
      </div> 
     </div> 
    </div> 
    </div> 
</div> 

在第一個「模體」課,我非常有信心,我的代碼是正確的,因爲它是我在做之前,現在我只是執行引導,使它看起來更優雅。

的問題發生在「模態軀」級爲第二個按鈕,其中的NG-單擊應該產生2個輸入:

Item 1 : [______] 
Calories : [_______] 

但由於某些原因,它不打算去了功能。我一直盯着過去8小時試圖找到一個錯誤,但我似乎無法找到任何。

+0

'addItem'是「formCtrl」的一種方法嗎? – mguimard

+0

是的,addItem是formCtrl的一種方法 – halapgos1

+3

那麼它應該在保存'ng-controller'屬性的div內 – mguimard

回答

1

您正在調用外部的formCtrl方法。在div.modal-content上移動ng-controller屬性,或在保存ng-controller屬性的div內移動button

+0

不能相信我錯過了......謝謝你!一雙新的眼睛def。幫助.. – halapgos1