<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script src="js/angular.js"></script>
</head>
<body ng-app="myApp" ng-controller="myctrl">
<input type="text" ng-model="textmodel" ng-keyup="mykey($event)"/>
<ul>
<li ng-repeat="x in list1 ">
{
{x}}
</li>
</ul>
<script>
var app = angular.module('myApp', []);
app.controller('myctrl', function ($scope) {
$scope.list1 = ['1', '2', '3'];
$scope.mykey = function (e) {
var keycode = window.event ? e.keyCode : e.which;//获取按键编码
if (keycode == 13) {
$scope.myClick();//如果等于回车键编码执行方法
}
}
$scope.myClick = function(){
if
angular input回车事件
最新推荐文章于 2024-04-16 23:58:22 发布