I've been tinkering around with a bit of code in AngularJS. I ran into a slight problem. I would like the user to select from 3 options... (Look below for my HTML for )
<label class="item item-input item-select">
<div class="input-label">
Frequentie
</div>
<select name="multipleSelect" id="multipleSelect" ng-model="data.multipleSelect">
<option value="eenmalig" >Eenmalig</option>
<option value="maandelijks">Maandelijks</option>
<option value="wekelijks">Wekelijks</option>
</select>
</label>
On request the code for the activating button:
<div class="bar ">
<input type="button"
ng-click=addToNgRepeatMinus("uitgiften");startAgain()
value="uitgaven"
class="button button-dark"
id="uitgiftenbutton">
<input type="button"
ng-click=addToNgRepeatPlus("inkomsten");startAgain()
value="inkomsten"
class="button button-dark"
id="inkomstenbutton">
</div>
Now my general understanding was that I could let certain things happen depending on which statement they would choose to select. (Which I am sure you can, but I just can't atm!)
first, I tried to use if, if else and else for it.. but I discovered that the if else statement isn't available in AngularJS.(Please correct me if it is!)
So naturally, I tried to use a switch.. which doesn't work sadly!
$scope.addToNgRepeatMinus = function(data) {
if(data === "uitgiften"){
switch(multipleSelect) {
case "eenmalig":
$scope.uitgiften.push({name: $scope.formulier.name,value: $scope.formulier.value});
break;
case "maandelijks":
$scope.uitgiften.push({name: $scope.formulier.name,value: $scope.formulier.value});
break;
case "wekelijks":
$scope.uitgiften.push({name: $scope.formulier.name,value: 4*$scope.formulier.value});
break;
}
}
};
This bit of code also interacts with certain buttons. (The function addToNgRepeatMinus gets activated when these buttons get pressed.) So when I press the button, It checks if the incoming data equals "uitgiften". If it does so, It should know that data.multipleSelect would equals either "eenmalig", "wekelijks" or "maandelijks" and then do the correct thing.
Can someone help me with this? What am I doing wrong ? :)
addToNgRepeatMinusfunction?