ucap-doc/documents/업무/3월/3째주/input-directive.html
Park Byung Eun 4acfaad2e8 0317 싱크
2020-03-17 18:09:38 +09:00

29 lines
807 B
HTML

<!doctype html>
<html ng-app="myApp">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script>
angular.module('myApp', [])
.controller('MyController', ['$scope', function($scope) {
$scope.hoge = "";
}])
// 日本語入力時に確定を押さなくてもng-modelを更新するdirective
.directive('jpInput', ['$parse', function($parse) {
return {
priority: 2,
restrict: 'A',
compile: function(element) {
element.on('compositionstart', function(e) {
e.stopImmediatePropagation();
});
},
};
}]);
</script>
<body>
<div ng-controller="MyController">
<input type="text" ng-model="hoge" jp-input>
{{hoge}}
</div>
</body>
</html>