2017-03-10 173 views
0
Here's the code.. 

<div class="input-wrapper"> 
<div class="col-xs-9 col-sm-10 col-md-11 col-lg-11"> 
<input type="text" class="form-control message-input" ng-keypress="($event.charCode === 13) ? vm.addMessage($event) : null" 
data-prod-idx="{{index}}" data-id="{{prod.ProductId}}" 
ng-model="vm.models.msgText" ng-init="vm.models.msgText=''" placeholder="Type your message here..."> 
</div> 
<button type="submit" class="btn btn-small btn-submit col-xs-2 col-sm-2 col-md-1 col-lg-1 message-send" ng-click="vm.addMessage($event)" data-prod-idx="{{index}}" data-id="{{prod.ProductId}}">Send</button> 
</div> 

我試圖實現消息聊天框,用戶可以在其中發送消息。點擊按鈕可以在任何地方工作,但onkeypress不適用於Firefox。輸入密鑰在Firefox中沒有提交數據..在IE和Chrome和Safari瀏覽器中工作正常

回答

0

charCode已棄用。請參閱MDN

enter image description here

+0

它不工作:( – Mohit

+0

@Mohit如果你只是要檢測的'Enter'關鍵。更換'charCode'到'keyCode'。現在 – wuxiandiejia

+0

工作...謝謝:) – Mohit

相關問題