<html ng-app="App" >
<head>
<title>邊做邊學angular-3 Event</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.15/angular.min.js"></script>
<script src="http://vitalets.github.io/checklist-model/checklist-model.js"></script>
</head>
<body>
<!-- controller where using ng -->
<div ng-controller="clickCtrl">
<div>
<h2>Click event</h2>
<input type="button" value="click" ng-click="testClick()">
</div>
</div>
<div ng-controller="changeCtrl">
<div>
<h2>Change event</h2>
<select ng-model="Select1" ng-options="m.ProductName for m in lotteryModel" >
<option value="">-- 請選擇 --</option>
</select>
<p>
you select index:{{Select1.id}}
</p>
</div>
</div>
<div ng-controller="checkCtrl">
<div>
<h2>check event</h2>
<div>
<label ng-repeat="city in lotteryModel">
<input type="radio" name="ckradio" ng-model="lotteryModel.index" value="{{city.id}}" >
<span>{{ city.ProductName}}</span>
</label>
</div>
<p>
you select index:{{ lotteryModel.index}}
</p>
</div>
</div>
<div ng-controller="checkBoxCtrl">
<div>
Value1: <input type="checkbox" ng-model="value1"> <br/>
Value2: <input type="checkbox" ng-model="value2" ng-true-value="YES" ng-false-value="NO"> <br/>
<tt>value1 = {{value1}}</tt><br/>
<tt>value2 = {{value2}}</tt><br/>
</div>
</div>
<div ng-controller="checkBoxCtrl2">
<div>
<h2>checkbox event using Checklist-model</h2>
<div>
<label ng-repeat="role in roles">
<input type="checkbox" checklist-model="user.roles" checklist-value="role.id"> {{role.text}}
</label>
</div>
<p>
user.roles {{ user.roles | json }}
</p>
</div>
</div>
<script>
var L2App = angular.module('App', ['checklist-model']);
L2App.controller('clickCtrl', function($scope) {
//click event
$scope.testClick = function() {
alert('click');
};
});
L2App.controller('changeCtrl', function($scope) {
//select item
$scope.lotteryModel = [
{
id: 1,
ProductName: '台北'
},
{
id: 2,
ProductName: '台中'
},
{
id: 3,
ProductName: '台南'
}];
});
L2App.controller('checkCtrl', function($scope) {
//select item
$scope.lotteryModel = [
{
id: 4,
ProductName: '台北'
},
{
id: 5,
ProductName: '台中'
},
{
id: 6,
ProductName: '台南'
}];
$scope.lotteryModel.index = 4;
});
L2App.controller('checkBoxCtrl', function($scope) {
//select item
$scope.value1 = true;
$scope.value2 = 'YES'
});
L2App.controller('checkBoxCtrl2', function($scope) {
$scope.roles = [
{id: 1, text: 'guest'},
{id: 2, text: 'user'},
{id: 3, text: 'customer'},
{id: 4, text: 'admin'}
];
$scope.user = {
roles: [2, 4]
};
});
</script>
</body>
</html>
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |