我正在使用cordova,离子和角度开发应用程序。在这个函数中,它应该从联系人中选择一个数字并用它来更新输入。
这是在ng-click中执行的:
$scope.buscarContato = function(){
$scope.phone = [];
$scope.phoneId = 0;
$scope.contact = [];
navigator.contacts.pickContact(function (contact){
$scope.$apply(function(){
$scope.contact = contact;
});
$scope.selecionarPhone(contact.phoneNumbers);
},function (err){
console.log('Error: ' + err);
});
};
$scope.selecionarPhone = function(phoneNumbers){
var phones = [];
var phoneId = [];
if(!phoneNumbers) return;
for(var i = 0; i < phoneNumbers.length; i++){
phones.push({"text": phoneNumbers[i].value});
phoneId.push( phoneNumbers[i].id );
}
var options = {
titleText: "Escolha o número a ser pesquisado",
buttons: phones,
cancelText: 'Cancelar',
cancelOnStateChange: true,
buttonClicked: function (index) {
$scope.phone = phones[index].text;
$scope.phoneId = phoneId[index];
$scope.contatoExiste = true;
return true;
}
};
$ionicActionSheet.show(options);
};
最后,更新输入:
$scope.phone = removerMascara(phones[index].text);
输入:
<input type="tel" placeholder="11999999999" name="phone" data-ng-model="phone" maxlength="15" required>
我对输入和范围本身有疑问。上面的执行正常发生,但如果我尝试手动更改输入,输入将停止更新,即使搜索仍然正常执行。
有没有人注意到我做错了什么?