Reputation: 41
I have an issue about the sending datas for update. I use this html form to posting data. I use this input on ng-repeat. So there are many inputs inside ng-repeat. When i try to post binded data from input i got "undefined" erorr. But if i write something manually into input i can post the value. But i need to send binded data from input.
<div ng-repeat="veri in veriler">
<form>
<input type="text" name="mac_id" ng-model="mac_id" ng-value="veri.mac_id">
<input type="submit" class="favourite" ng-click="addtofavourite(mac_id)">
</form>
</div>
Then i try to post data with this code;
$scope.veri = {};
$scope.addtofavourite = function(mac_id){
var link = 'http://example.com/api.php';
var mac_id = mac_id;
var user_id = loggeduser;
alert (mac_id);
$http.post(link, {user_id : user_id, mac_id : mac_id}).then(function (res){
$scope.response = res.data;
});
};
Best regards.
Upvotes: 0
Views: 28
Reputation: 471
Selam :) Can you please try this code?
<div ng-repeat="veri in veriler">
<form>
<input type="text" name="mac_id" ng-model="veri.mac_id" >
<input type="submit" class="favourite" ng-click="addtofavourite(veri.mac_id)">
</form>
</div>
Upvotes: 1