@iJB wrote:
Hey Community,
Im working on an App and you should be able to push Data in an Array.
I console logged the array, the inputs and everything works fine, except of that this isnt showing up in the ng-repeat.
Here is my code, maybe you can help me.index.html
<script id="templates/addEx.html" type="text/ng-template"> <ion-view view-title="GymHelper"> <ion-content padding="true" ng-controller="OverallCtrl"> <div class="list"> <label class="item item-input item-floating-label"> <span class="input-label">Exercise Title</span> <input ng-model="exer.title" type="text" placeholder="Title"> </label> <label class="item item-input item-floating-label"> <span class="input-label">Exercise Sets</span> <input ng-model="exer.set" type="text" placeholder="Sets"> </label> <label class="item item-input item-floating-label"> <span class="input-label">Exercise Reps</span> <input ng-model="exer.rep" type="text" placeholder="Reps"> </label> <label class="item item-input item-floating-label"> <span class="input-label">Extra Information</span> <input ng-model"exer.inf" type="text" placeholder="Extra Information"> </label> <label class="item item-input item-select"> <div class="input-label"> Muscle </div> <select ng-model="selOption"> <option>Chest</option> <option>Biceps</option> <option>Back</option> <option>Stomach</option> <option>Legs</option> <option>Triceps</option> <option>Shoulders</option> <option>Traps</option> </select> </label> </div> <button class="button button-block button-positive" ng-click="createEx(exer)"> Create Exercise </button> </ion-content> </ion-view> </script> <script id="templates/chest.html" type="text/ng-template"> <ion-view view-title="GymHelper"> <ion-content ng-controller="OverallCtrl"> <ion-checkbox ng-repeat="chest in chestEx"> <b class="exTitle">{{chest.title}}</b> <h3 class="exSets">Sets: {{chest.sets}}</h3> <h3 class="exReps">Reps: {{chest.reps}}</h3> <h3 class="exInf">{{chest.exInf}}</h3> </ion-checkbox> </ion-content> </ion-view> </script>
app.js
app.controller('OverallCtrl', function($scope, $ionicListDelegate, $state) { $scope.chestEx = [ {title: "Crowls", sets: 3, reps: 15, exInf: "Make 5 minute pause between Sets."}, ] $scope.selOption == "Chest"; $scope.createEx = function(exer) { console.log(exer.title); console.log($scope.chestEx); if($scope.selOption == "Chest"){ $scope.chestEx.push({title: exer.title, sets: exer.set, reps: exer.rep, exInf: exer.inf}); console.log("Pushed to Chest Array."); $state.go('chest') }; } })
Posts: 1
Participants: 1