我想从输入框中获取数据,然后单击按钮将其保存在数据库中。我正在使用角度。如何从表单中获取这些数据?请帮我。 我有以下HTML代码:
import { IonicModule } from 'ionic-angular'
和Angular代码:
<form ng-submit="createUser(userForm.$valid)" name="userForm1">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="database_address">User</label>
<input type="text" class="form-control1" ng-model="usernamee" placeholder="Потребителско Име..." />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="text" class="form-control1" ng-model="passwordd"required id="password" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="username">Operator</label>
<input type="text" class="form-control1" ng-model="namee" required id="username" />
</div>
</div>
</div>
<button class="btn btn-primary" ng-click="createUser();" type="submit">Add user</button>
<!--<button class="btn btn-primary" ng-disabled="userForm.$invalid" type="submit">Добавяне на нов</button>-->
</form>
答案 0 :(得分:0)
<form ng-submit="createUser(userForm)" name="userForm">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label for="database_address">User</label>
<input type="text" class="form-control1" ng-model="user.usernamee" placeholder="Потребителско Име..." />
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="text" class="form-control1" ng-model="user.passwordd"required id="password" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<label for="username">Operator</label>
<input type="text" class="form-control1" ng-model="user.namee" required id="username" />
</div>
</div>
</div>
<button class="btn btn-primary" type="submit">Add user</button>
</form>
angularjs代码
$scope.user={}//declare user object
$scope.createUser=function(userForm)
{
console.log($scope.user);
//for saving data in database, you'll need an API along with the backend.
}
答案 1 :(得分:0)
我在我的应用程序中使用的是“ Sequelize”方法。是否可以使用此方法与数据库建立此连接?