I have a form where I need to edit input values. For instance, I have a number of input controls that I want to change the value before the POST happens. I my html:
<input type="text" name="bar" id="bar" ng-model="foo.bar"/>
My Go struct:
type Foo struct{
Bar string `json:"bar"`
}
My Angular controller:
Restangular.all('drugs/new').post($scope.drug).then(......
Before I call .post(), I want to get the input element and set a value. When I do so, right before this POST call, the new value does not get sent in the json.
I'm assuming that the value of $scope.drug
relates directly to the values of those inputs because otherwise you would have posted the relevant code, wouldn't you.
AngularJS provides 2-way bindings which means that if the value of $scope.drug
depends directly on the input elements you mention, then the relation also goes in the other way i.e. if you change the value of $scope.drug
, then the inputs will change.
So the solution is simple; change the value of $scope.drug
.