I'm in need of your help. I just starting working with AngularJS and I have encountered a problem with code that is written in Boostrap see snippet.
There is a form and below it I need to add something a few options simillar to radio buttons/check box.
EXAMPLE: So first you pick one or more items from the existing form, and then below it you can choose one of those 2-3 checkboxes. After selecting those, it all sums up in the Total Cost.
View image >>> https://s18.postimg.org/chgy451ix/Screenshot_1.png
var myApp = angular.module("MyApp", []);
myApp.controller("MyCtrl", function($scope){
$scope.menuCard = [
{item: "Egg and Cheese", cost:30, active:true},
{item: "Breakfast Sandwich", cost:400, active:false},
{item: "Blueberry Pancakes", cost:250, active:false},
{item: "Cheese Omelet ", cost:220, active:false},
];
$scope.total = 30;
$scope.toggleActive = function(c)
{
c.active = !c.active;
if(c.active)
{
$scope.total += c.cost;
}else
{
$scope.total -= c.cost;
}
}
});
body{font:20px/1.3 'Open Sans', sans-serif; color: #5e5b64; margin:0; padding:0;}
.container{
margin-top:50px;
}
span{float:right;}
<html data-ng-app = "MyApp">
<head>
<title>AngularJS - DataBinding</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-ng-controller = "MyCtrl">
<div class = "container">
<div class = "row">
<div class = "col-md-4 col-md-offset-3">
<h2 class = "text-center"><strong>Order Form</strong></h2>
<div class="list-group">
<button type="button" class="list-group-item" data-ng-repeat = "item in menuCard" data-ng-click = "toggleActive(item)" ng-class="{active:item.active}">{{item.item}}<span>{{ item.cost | currency }}</span></button>
</div>
<hr/>
<div class="alert alert-success" role="alert">Total Cost: <span>{{ total | currency }}</div>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
</body>
</html>