ionic将值设置为结果的输入

时间:2017-01-29 09:02:04

标签: angularjs ionic-framework

我正试图设定一个价值" postid"我是从json" {{postDetail.post.id}}"隐藏输入,然后用表单

发送
    <form ng-submit="submit()">
                    <label class="item item-input item-stacked-label">
                        <span class="input-label">Username :</span>
                        <input type="text" name="username" placeholder="enter username" ng-model="data.username">
                        <input type="hidden" value="{{postDetail.post.id}}" name="postid" ng-model="data.postid">

                    </label>
 <label class="item item-input item-stacked-label">
                        <span class="input-label">Comment :</span>

  <textarea placeholder="yyy" rows="8" cols="10"  placeholder="Write your comment" ng-model="data.body">
  </textarea>
                    </label>         <input class="button button-block button-positive" type="submit" name="submit" value="Submit to server">                    
                </form>

这是我的js代码

.controller('PostDetailController', function(Posts, $stateParams, $scope, $ionicLoading, $http) {
        var _this = this;
        $scope.data = {};

    $scope.submit = function(){
        var link = 'http://localhost/json/comment.php';

        $http.post(link, {username : $scope.data.username, body : $scope.data.body, postid : $scope.data.postid}).then(function (res){
            $scope.response = res.data;
        });
    };

0 个答案:

没有答案