作者:alilx | 来源:互联网 | 2023-09-14 10:02
ImtryingoutIonicAngularJSforthefirsttime,andarecreatingasimpleloginwithtokensentv
I'm trying out Ionic/AngularJS for the first time, and are creating a simple login with token sent via mobile.
我第一次尝试了Ionic/AngularJS,并创建了一个简单的通过mobile发送的令牌登录。
I've got an input field for phone number and an input field for the token/code.
我有电话号码的输入字段和令牌/代码的输入字段。
At first only the phone number input field is visible, but when a user request a code, the code input field should become visible. As soon as a user has entered a 4 digit code, the button should change from "Get code" to "Log in" and call the function with 2 parameters.
首先,只有电话号码输入字段是可见的,但是当用户请求代码时,代码输入字段应该是可见的。当用户输入4位数字代码时,按钮应该从“Get code”改为“Log in”,并调用带有两个参数的函数。
This is my code so far: http://codepen.io/anon/pen/PZOOBz
这是我目前的代码:http://codepen.io/anon/pen/PZOOBz
I'm kind of stuck with changing the button text and behavior after a user has entered the phone number.
在用户输入了电话号码后,我不得不更改按钮文本和行为。
HTML:
HTML:
JS:
JS:
angular.module('Hello', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('signin', {
url: '/signin',
templateUrl: 'templates/signin.html',
controller: 'SignInCtrl'
})
.state('home', {
url: '/home',
templateUrl: 'templates/home.html'
});
$urlRouterProvider.otherwise('/signin');
})
.controller('SignInCtrl', function($scope, $state) {
$scope.signIn = function(phoneNumber, code) {
console.log('Sign In Phone Number', phoneNumber);
console.log('Sign In Code', code);
$state.go('home');
};
$scope.signIn = function(phoneNumber) {
console.log('Sign In Phone Number', phoneNumber);
};
});
3 个解决方案