submit / ng-onclick 仅在我第一次单击它时才有效。我使用 Ionic 框架(如果这可能对某人有帮助)来创建一个应用程序。
我对这些东西真的很陌生...
JS
.controller('CustomerCtrl', function($scope, $stateParams) {
db.get($stateParams.customerId, function(err,doc) {
$scope.customer = doc;
//$scope.$apply();
});
$scope.doUpdate = function(customer) {
db.put(customer, function(err, response) {
if (!err) {
console.log("Successfully Updated the Doc")
}
//$scope.formc.$setPristine(); // removes ng-dirty doesnt help
});
}
})
的HTML
<div ng-controller="CustomerCtrl">
<form name="formc" novalidate>
<div class="list">
<label class="item item-input">
<span class="input-label">Name</span>
<input type="text" ng-model="customer.name">
</label>
<label class="item item-input">
<span class="input-label">Adresse</span>
<input type="text" ng-model="customer.address">
</label>
</div>
<button type="submit" class="button button-large" ng-click="doUpdate(customer)">
Submit
</button>
</form>
</div>