<!-------------------- 輸入框按鈕組 -----------------------> <section class="common_input_button_style top_10"> <label class="item item-input"> <i class="icon ion-android-phone-portrait placeholder-icon"></i> <input type="tel" placeholder="請輸入手機號碼" autofocus ng-model="data.phoneNumber"> </label> <div class="common_button"> <button class="button button-block button-calm" ng-disabled="data.disabled" ng-click="action.toSendVerifyMessagePage()">下一步 </button> </div> </section>
*監聽<input type="tel" placeholder="請輸入手機號碼" autofocus ng-model="data.phoneNumber">輸入框中文本的變化。android
angular.module('MrTrustApp.controllers') .controller('AuthLoginRegisterCtrl', function ($scope, StateGo, $ionicPopup) { //定義數據 $scope.data = {}; $scope.data.phoneNumber = '17789763630'; //匹配手機號碼成功,則按鈕可用 $scope.$watch('data.phoneNumber', function (newVal, oldVal) { <!--TODO: 正則匹配 各類 電話號碼 --> if (/\d{11}/.test(newVal)) { $scope.data.disabled = false; } else { $scope.data.disabled = true; } });
});