I have a Go struct:
type Foo struct {
Name string `json:"fooName"`
Things []string `json:"things"`
}
I have an Angular html page:
<input type="text" name="fooName" ng-model="foo.fooName"/>
<div ng-repeat="thing in things">
<input ng-model="foo.things" type="text" name="thing-{{$index}}"/>
</div>
In the Angular controller I have:
$scope.save= function(){
Restangular
.all('foos/new')
.post($scope.foo).then(function(foo) {
$location.path('/admin/fooManagement');
});
};
The rest service call calls:
func CreateFoo(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
var f Foo
dec := json.NewDecoder(r.Body)
dec.Decode(&f)
log.Println("**** CreateFoo.... ")
log.Println(&d)
}
Foo's name comes through, but I cannot get the "Things" array populated with the input values. I'm trying to figure out how to get the post service call to populate the array.
name="thing[{{$index}}]"
– tomwilde yesterday