Javascript 如何将数据从标签传递到控制器
signup.htmlJavascript 如何将数据从标签传递到控制器,javascript,sqlite,ionic-framework,Javascript,Sqlite,Ionic Framework,signup.html <ion-view view-title="Sign Up" > <ion-content class="padding"> <div class="list"> <label class="item item-input item-floating-label"> <span class="input-label">First Name</span>
<ion-view view-title="Sign Up" >
<ion-content class="padding">
<div class="list">
<label class="item item-input item-floating-label">
<span class="input-label">First Name</span>
<input type="text" placeholder="First Name">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Last Name</span>
<input type="text" placeholder="Last Name">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Email</span>
<input type="text" placeholder="Email">
</label>
<label class="item item-input item-floating-label">
<span class="input-label">Password</span>
<input type="text" placeholder="password">
</label>
<button class="button button-block button-positive"ng-click="insert('averyto8@vt.edu')">
Sign-Up
</button>
</div>
</ion-content>
</ion-view>
我正在尝试将所有成员信息传递到app.js文件中的控制器中。我似乎找不到如何将用户生成的数据从html发送到控制器。任何帮助都将不胜感激 我只为
firstname
做过,其他字段也是一样的
signup.html
<ion-view view-title="Sign Up" >
<ion-content class="padding">
<div class="list">
<label class="item item-input item-floating-label">
<span class="input-label">First Name</span>
<input type="text" ng-model="data.firstname" placeholder="First Name">
</label>
<button class="button button-block button-positive"ng-click="insert()">
Sign-Up
</button>
</div>
</ion-content>
</ion-view>
通过在输入标记上使用ng模型指令。然后你可以通过$scope变量在你的控制器中访问它们。我知道了,对不起,我是爱奥尼亚的新手,你能给我指个地方让我熟悉$scope变量吗?如果下面听起来像广告,只需谷歌“如何开始使用爱奥尼亚框架”,你就会偶然发现我为Pluralsight写的文章。实际上,我在我的博客上写了很多关于爱奥尼亚主题的教程。另外,你可以看看我的10k单词指南:。最后,如果您愿意,您也可以免费获得我关于爱奥尼亚的书:。祝你学习顺利!
<ion-view view-title="Sign Up" >
<ion-content class="padding">
<div class="list">
<label class="item item-input item-floating-label">
<span class="input-label">First Name</span>
<input type="text" ng-model="data.firstname" placeholder="First Name">
</label>
<button class="button button-block button-positive"ng-click="insert()">
Sign-Up
</button>
</div>
</ion-content>
</ion-view>
angular.module('starter', ['ionic']).controller("MembersController", function ($scope, $cordovaSQLite) {
$scope.data = {};
var firstname;
$scope.insert = function () {
firstname = $scope.data.firstname;
var query = "INSERT INTO people (email, password, firstname, lastname, gender, dateJoined, weeklyPoints, totalPoints) VALUES (?,?,firstname,?,?,?,0,0)";
$cordovaSQLite.execute(db, query, [email, password, firstname, lastname, gender, dateJoined, weeklyPoints, totalPoints]).then(function (res) {
alert("INSERT ID -> " + res.insertId);
}, function (err) {
alert(err);
});
};
});