How to Use ionic to block the input box when developing ios system (Keyboard pop-up problem), ionicios
When developing IOS systems using ionic, there will be an annoyance. when filling out the form, the keyboard will block the input box, which is not a big problem, you can see the input box immediately after entering a word.
It is a pity that some customers do not care about this problem, but they do not. So they suddenly woke up and came up with this solution when they went to bed one day.
I will not elaborate on the code.
angular.module('MyApp').directive('focusInput', ['$ionicScrollDelegate', '$window', '$timeout', '$ionicPosition', function ($ionicScrollDelegate, $window, $timeout, $ionicPosition) {return {restrict: 'A',scope: false,link: function ($scope, iElm, iAttrs, controller) {if (ionic.Platform.isIOS()) {iElm.on('focus', function () {var top = $ionicScrollDelegate.getScrollPosition().top;var eleTop = ($ionicPosition.offset(iElm).top) / 2var realTop = eleTop + top;$timeout(function () {if (!$scope.$last) {$ionicScrollDelegate.scrollTo(0,realTop);} else {try {var aim = angular.element(document).find('.scroll')aim.css('transform', 'translate3d(0px,' + '-' + realTop + 'px, 0px) scale(1)');$timeout(function () {iElm[0].focus();console.log(2);}, 100)} catch (e) {}}}, 500)})}}}}])