Skip to content

Instantly share code, notes, and snippets.

@phi-jp
Created May 30, 2014 04:23
Show Gist options
  • Save phi-jp/f556a8148a7be60c3d7e to your computer and use it in GitHub Desktop.
Save phi-jp/f556a8148a7be60c3d7e to your computer and use it in GitHub Desktop.
[AngularJS][tips] Toggle ボタン作ってみた ref: http://qiita.com/phi/items/2a59ccd83006e9209494
ng-click="hoge=!hoge"
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="UTF-8" />
<title>AngularJS Sample</title>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<script src="http://code.angularjs.org/1.2.0-rc.2/angular.min.js"></script>
<style>
body {
padding: 50px;
}
</style>
<script>
function SampleCtrl($scope) {
$scope.flag = true;
};
</script>
</head>
<body>
<div ng-controller="SampleCtrl" class="container">
<button class="btn btn-info btn-lg" ng-click="flag=!flag" ng-class="{open:flag}">{{flag}}</button>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment