I have a radio button, which sets the value of True
or False
based on the value of transaction type
The demo can be found here
The problem is when I click on any of the radio button, the value of $scope.transaction.debit
does not change
My javascript code is
var app = angular.module('myApp', []);
app.controller("MainCtrl", function($scope){
$scope.transaction = {};
$scope.transaction.debit=undefined;
console.log('controller initialized');
});
Please let me know what I am doing wrong.
Also, I do not want to use Angular-UI
or AngularStrap
for this purpose, unless no other option is available.
I modified dpineda's solution. You can use without removing bootsrap.js dependency. Also there is a working example here.
This is the flow:
data-toggle="buttons"
for preventing bootstrap execution.html
JavaScript
Style
I had the same problem. Use ng-click on your labels and it will work fine with bootstrap
Here it's working in plunker
Here's a working version using a new directive:
html
javascript
if you remove de bootstrap code you can control the styles with conditionals
Based on francisco.preller's answer I wrote two solutions trying to make it fit for generic use, without loosing the input tags: html:
solution #1:
Solution #2:
I have a feeling the first one is better because it make angular do the updating work.
You have a large label stuck over the top of the radio buttons which prevents input to your radio buttons. The html should read:
It then works, of course it may not look the way you want it to then.