I have an array of places I'm looping through using ng-repeat. I have a
function that adds to the array and I can confirm that the array is being
updated. The view isn't updating after I add to the array anymore, what
could cause this issue?
Here is the code responsible for looping through the array.
<div class="place card text-white bg-success mb-3" ng-repeat="place in
places | filter:searchFor">
<div class="card-header">
<a href="/index.html#/place/{{place.name}}">{{place.name}}</a>
</div>
<div class="card-body">
{{ place.state }} - {{ place.temp }}
</div>
</div>
Here is the form that catches the data.
<form name="add_place_form">
<div class="place card text-white bg-danger mb-3">
<div class="card-header">
<h3>Add new place</h3>
</div>
<div class="card-body">
<div class="alert alert-warning" ng-show="add_place_error">{{
add_place_error }}</div>
<input name='date' class="mb-3" type="text" placeholder="Name" size="20"
ng-model="adding_place.name"/>
<input class="mb-3" type="text" placeholder="State" size="20"
ng-model="adding_place.state"/>
<input class="mb-3" type="text" placeholder="Temp" size="20"
ng-model="adding_place.temp"/>
<p style="float:right;"><button type="button" class="btn btn-primary"
ng-click="addPlace(adding_place)">Submit</button></p>
</div>
</div>
</form>
Here is the function that passes the information to the service.
$scope.addPlace = function(new_place) {
placeProvider.addPlace(new_place);
$scope.adding_place = {};
$scope.add_place_error="";
}
Here is the function that actually adds the data to the array.
this.addPlace = function(place_data){
places.push(place_data);
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.