1
각도 ui를 간단히 사용하는 데 문제가 있습니다. 예를 들어, 추가 버튼을 누르지 않고도 텍스트 상자에 enter
을 누르면 항목을 자동으로 추가하기 위해 키 누르기를 쉽게 감지 할 수 있기를 원합니다. http://jsfiddle.net/NbjZL/5/ :각도 UI 키 누름이 작동하지 않습니다.
<!DOCTYPE html>
<html ng-app xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Main</title>
<link rel="stylesheet", href="http://angular-ui.github.com/angular-ui/build/angular-ui.css" />
</head>
<body ng-controller="Ctrl">
<button ng-click="add()">Add</button>
<input type="text" ui-keypress="{enter: 'add()'}" />
{{item}}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"> </script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
<script src="http://angular-ui.github.com/angular-ui/build/angular-ui.js"></script>
<script src="main.js"></script>
</body>
</html>
var myApp = angular.module('myApp', ['ui.directives']);
function Ctrl($scope) {
$scope.item = "";
$scope.add = function() {
$scope.item = "Item Added";
}
}
당신이있어 행동을 볼 수
여기에 내 현재의 시도입니다. 텍스트를 입력 한 후에 버튼을 클릭해도 텍스트를 입력 한 후에 enter
을 누르면 작동하지 않습니다. 나는 어떤 문서를 찾을 수 있었는지 읽고 몇 가지 예제를 살펴 봤지만, 나는 아직도 작은 것을 놓치고 있다고 확신한다.
윽 볼 수 있습니다! 나는 그 작은 속성이 실제로 나를 결국 물려 줄 것이라는 것을 알지 못한다는 것을 알았다. 선생님 께 많은 명예를 전합니다! – jtheis