直接上代码我没写指令直接这么用的:
html:
<div class="box_ft_cont"> ???????<div class="chat_text"> ??????????????<textarea id="serializeInfo" data-ng-trim="false" ng-model="chat.sendContent" ng-keyup="sendChats($event)" ui-jq="slimScroll" ui-options="{height:‘100%‘, size:‘8px‘, width:‘100%‘}" type="text" class="chat-cont"></textarea> ????????</div> ????????<p class="chat-btn"> ????????????????<span>按enter键发送</span> ?????????????????<button type="submit" ng-click="sendChat()" class="btn btn-primary"><i class="fa fa-paper-plane"></i></button> ????????</p> </div>
js部分:
?//发送消息 ?$scope.sendChat = function () { ?????var message = {}; ?????message.fromUserName = ""; ?????message.toUserName = $scope.chat.currUserId; ?????message.content = $scope.chat.sendContent; ?????message.msgType = 0; ?????message.sendTime = $filter(‘date‘)(new Date(), "yyyy-MM-dd hh:mm:ss"); ?????myWebsocket.sendMessage(message); ?????$scope.chat.sendContent = null; ?} ?$scope.sendChats = function (event) { ?????if (event.keyCode == 13) { ?????????$scope.sendChat(); ?????????return false; ?????} ?}
angularJS的ng-keyup
原文地址:http://www.cnblogs.com/bertha-zm/p/8043800.html