angularjs radio checkbox, +pop array,
angularjs , jQuery,
checkbox as radio buttons,
replace false strong to '',
by Seetpal Singh
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-rc.2/angular.min.js"></script>
<div ng-controller="MainCtrl">
<h1> With ng-repeat </h1>
<div>
<input type="checkbox" ng-model="result.result" ng-true-value="'11'">
<input type="checkbox" ng-model="result.result" ng-true-value="'12'">
<input type="checkbox" ng-model="result.result" ng-true-value="'13'">
<input type="checkbox" ng-model="result.result" ng-true-value="'14'">
<input type="checkbox" ng-model="result.result" ng-true-value="'15'">
</div>
<br/>
<div>
<input type="checkbox" ng-model="result.final" ng-true-value="'11j'">
<input type="checkbox" ng-model="result.final" ng-true-value="'12gh'">
<input type="checkbox" ng-model="result.final" ng-true-value="'13'">
<input type="checkbox" ng-model="result.final" ng-true-value="'14j'">
<input type="checkbox" ng-model="result.final" ng-true-value="'15'">
</div>
result = {{result}}
<br/> Model = {{bim}}
<br/> poped = {{poped}}
<br/> poped = {{output}}
<br/>
</div>
JavaScript
var app = angular.module('creators_guru', []);
app.controller('MainCtrl', function($scope) {
$scope.result = {
result: '',
final: ''
};
$scope.poped = {
result: '',
final: ''
};
$scope.bim = '';
$scope.$watchCollection('result', function(newvalue, old) {
$scope.bim = '';
$scope.poped = {};
angular.forEach($scope.result, function(value, key) {
if (!value) {
$scope.bim = 'got 0';
//value = '';
//delete $scope.poped[key];
$scope.poped[key] = '';
} else {
//$scope.poped.push(key + ': ' + value);
//var dict = {};
//dict[key] = value;
$scope.poped[key] = value;
}
});
$scope.output = $scope.poped.final + $scope.poped.result;
/*
angular.forEach($scope.result, function(value, key){
if(!value){
$scope.bim = 'got 0';
value = '';
}
$scope.bim = 'got 1';
this.push(key + ': ' + value);
}, poped);
*/
});
});
angular.bootstrap(document, ['creators_guru'])