Angularjs 将值设置为结果的输入
我试图将从json“{{postDetail.post.id}”中获得的值“postid”设置为隐藏输入,然后将其与表单一起发送Angularjs 将值设置为结果的输入,angularjs,ionic-framework,Angularjs,Ionic Framework,我试图将从json“{{postDetail.post.id}”中获得的值“postid”设置为隐藏输入,然后将其与表单一起发送 <form ng-submit="submit()"> <label class="item item-input item-stacked-label"> <span class="input-label">Username :<
<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代码样本问题出在什么地方。是在表单提交`$scope.data.postid`未设置之后吗?是的,我确实想提交{{postdail.post.id}表单,但它不起作用
.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;
});
};