zoukankan      html  css  js  c++  java
  • angularJS的ng-keyup

    直接上代码我没写指令直接这么用的:

    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', '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;
          }
      }
  • 相关阅读:
    理解JAVA常量池
    java存储位置经典例子
    java通过句柄访问对象
    常用排序算法小结
    String,StringBuffer与StringBuilder的区别
    BGP
    BGP
    python编码问题实例
    从一段代码学习二叉树
    二叉树学习笔记--先序遍历
  • 原文地址:https://www.cnblogs.com/bertha-zm/p/8043800.html
Copyright © 2011-2022 走看看