i have used this method it works good bt it work for single checkbox if you i select multiple checkbox it doesn't check correctly
See the below jsfiddle need to add
<script src="http://ift.tt/28R9QNn"></script>
i added into jsfiddle's resource file but it does not work
See the above jsfiddle
<!DOCTYPE html>
<html>
<script src="http://ift.tt/1Mrw6cj"></script>
<script src="http://ift.tt/28R9QNn"></script>
<body>
<div ng-app="myApp" ng-controller="Ctrl1" class="row">
<label ng-repeat="role in roles">
<input type="checkbox" name="sportId" ng-required="!sportId" data-checklist-model="player.sport_id" data-checklist-value="role.id" ng-click="myFunction(role.id)"> </label>
<div>
<h3>Result</h3>
<pre></pre>
</div>
</div>
<script>
var app = angular.module("myApp", ["checklist-model"]);
app.controller('Ctrl1', function($scope) {
$scope.roles = [
{id: 1, text: 'H'},
{id: 2, text: 'S'},
{id: 3, text: 'L'},
{id: 4, text: 'G'},
{id: 5, text: 'F'},
{id: 6, text: 'O'}
];
$scope.player = {
roles: [$scope.roles[1]]
};
$scope.myFunction = function(id){
if($scope.player.sport_id == true){
alert("checked");
}else{
alert("unChecked");
}
};
});
</script>
</body>
</html>
What i need it should says on every checkbox if it is checked say "checked" if uncheck say "unchecked"
Aucun commentaire:
Enregistrer un commentaire