如何将数据从标签传递到控制器

时间:2016-03-01 20:36:40

标签: javascript sqlite ionic-framework

signup.html

channel = stream.channel

app.js

channel = Channel.objects.get(stream=stream)

我正在尝试将所有这些成员信息传递到app.js文件中的控制器中。我似乎无法找到如何将用户生成的数据从我的HTML发送到控制器。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我只为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>

<强> app.js

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);
        });
    };
});