Skip to content

Instantly share code, notes, and snippets.

@kfly8
Created August 21, 2014 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfly8/e65bb6e9b5f1425e2d9d to your computer and use it in GitHub Desktop.
Save kfly8/e65bb6e9b5f1425e2d9d to your computer and use it in GitHub Desktop.
angular sample
<!doctype html>
<html ng-app='sample'>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<script>
angular.module('sample', [])
.controller('MainCtrl', ['$scope', function($scope) {
$scope.bulk_check = function() {
angular.forEach($scope.items, function(item) {
item.ng_checked = $scope.bulk_check_fg;
});
};
}]);
</script>
</head>
<body>
<div ng-controller="MainCtrl" ng-model="items" ng-init="items = [{ 'name':'ほげ' }, { name:'ふが' }]">
<input type="checkbox" ng-model="bulk_check_fg" ng-change="bulk_check()">一括
<ul>
<li ng-repeat="item in items">
<input type="checkbox" ng-checked=item.ng_checked ng-model=item.ng_checked>{{item.name}}:{{item.ng_checked}}
</li>
</ul>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment