0

I am using AngularJs and have inputs with predefined value from ng-repeat. I want resend those data value via ng-click function to treat data.

The problem the data is not submitted

<label>Price</label>
<input type="text" class="form-group form-control" ng-value=s.prix required="required" ng-model="prix"  >
</div>
<div class="modal-footer">
<button type="submit" id='submit' ng-click="edit()" class="btn btn-primary"  data-dismiss="modal">Save</button>

s.prix is a value of column in the table prix (ng-repeat="s in produit") if you know what i mean.

2
  • here's my controller Commented Feb 19, 2016 at 13:29
  • the function $scope.edit = function(){ alert($scope.prix); }; here when the alert shows it says prix is undifined Commented Feb 19, 2016 at 13:29

2 Answers 2

0

Use ng-repeat instead as model

Like this

<input type="text" class="form-group form-control" required="required" ng-model="s.prix"  >

Then pass object in edit.

Try like this

ng-click="edit(s)"

JS

$scope.edit=function(s){
  console.log(s);
}
Sign up to request clarification or add additional context in comments.

1 Comment

the think is i don't want the same value am updating the prix field !! if you pass the object it will send you the default row without update §§
0

html:

<body ng-controller="myCtrl">

<label>Price</label>
<div ng-repeat="s in produit">
<input type="text" class="form-group form-control" required="required" ng-model="s.prix"  >
<button type="submit" id='submit' ng-click="edit(s)" class="btn btn-primary"  data-dismiss="modal">Save</button>
</div>

</body>

controller:

myApp.controller('produitCtrl', ['$scope',function($scope){

    $scope.produit = [{prix:'hello'}];

    $scope.edit=function(s){
          console.log(s);
        }

}]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.