I want to have a radio-button group as you can see in my code. I use AngularJs, Angular-Strap and Bootstrap.
The problem is, that my variables in the controller won't update when I click another button. The default value is set. If i remove the labels around the input tags, the update occurs... I don't know if this is a bug, or if I am making something wrong..
I hope I provided any information you need. Thanks for any help!!
Versions: AngularJS: 1.2.16 AngularStrap: 2.0.2 Bootstrap :3
HTML:
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<link href="Content/style.css" rel="stylesheet" />
<link href="Content/bootstrap-additions.css" rel="stylesheet" />
<link rel="stylesheet" href="//rawgithub.com/mgcrea/angular-motion/master/dist/angular-motion.min.css">
Radio Button:
<label class="control-label">Group By:</label>
<div class="btn-group" ng-model="groupBy.value" data-bs-radio-group>
<label class="btn btn-default" for="all">
<input name="all" type="radio" class="btn btn-default" value="all">
All
</label>
<label class="btn btn-default" for="room">
<input name="room" type="radio" class="btn btn-default" value="room">
Room
</label>
<label class="btn btn-default" for="category">
<input name="category" type="radio" class="btn btn-default" value="category">
Category
</label>
</div>
Used Libraries:
<script src="libraries/angular.min.js"></script>
<script src="libraries/jquery.min.js"></script>
<!-- UI Libs -->
<script src="libraries/bootstrap.min.js"></script>
<script src="libraries/angular-strap.min.js"></script>
<script src="libraries/angular-strap.tpl.min.js"></script>
Controller:
$scope.groupBy = {
value: 'room'
};
Update:
Module Definition:
var app = angular.module('deviceApp', ['ngRoute','mgcrea.ngStrap','ngAnimate']);
app.config(function ($routeProvider) {
$routeProvider
.when('/devices',
{
controller: 'DeviceController',
templateUrl: '/app/partials/devices.html'
})
.otherwise({ redirectTo: '/devices' });
});
app.controller('DeviceController', function ($scope, $log, $alert, deviceService) {
$scope.groupBy = {
value: 'room'
};
...
<html data-ng-app="deviceApp">
...
for
attribute of labels? Can you remove them? You code can get work by simply removingfor
attribute of labels. – Hydromancyfor
: plnkr.co/edit/SUdgv5rIVdJMLhiHFOiJ?p=preview – Subgenus