1
我有一个输入框按钮的输入值获取有关点击页面
<div class="inputs">
<label>Online Payment ID</label>
<input type="text" class="form-control" ng-model="payId">
</div>
我有一个按钮,页面有些地方说
<button type="button" class="btn" ng-click="proceedPayment()" ></button>
现在
上点击proceedPayment()
将被称为,从那里我需要检查上面的文本fild输入的值使用
我试过,
$scope.proceedPayment = function() {
alert($scope.payId); // Always alerts undefined
if (!$scope.payId) {
$scope.payIdError = true;
console.log('No value entered');
} else {
$scope.payIdError = false;
console.log('value entered');
}
}
但这不起作用 我不想在这里使用窗体。我是一个有角度的初学者,感谢您的帮助!
@Satpal错字错误! – monda
在函数中访问之前初始化'$ scope.payId'。像这样:'$ scope.payId = 10' –
你可以使用一个表单,然后使用角度验证:https://docs.angularjs.org/guide/forms –