<html>
<head>
<meta charset="utf-8">
<title>ng-model-options in 5 minutes</title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,400,700">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>
<body ng-app="iLoveAngularᕕ( ᐛ )ᕗ<--dontDoThisNormally" ng-controller="ᕙ(⇀‸↼‶)ᕗCtrl<--orThis as vm">
<h1>
ng-model-options
<small>
in 5 minutes<br />
with <a href="https://twitter.com/kentcdodds">@kentcdodds</a>
</small>
</h1>
<hr />
<div>
<strong class="title">Form</strong>
<form name="vm.lightsaberForm">
<div class="form-group" ng-class="{'has-error': vm.lightsaberForm.fullName.$invalid && vm.lightsaberForm.fullName.$touched}">
<label for="fullName" class="control-label">Full Name</label>
<input name="fullName"
id="fullName"
type="{{::vm.inputType}}"
class="form-control"
ng-model="vm.user.fullName"
ng-model-options="vm.modelOptions"
required
ng-maxlength="25"
placeholder="{{::vm.inputType}}: required, minlength 5, maxlength 25"
minlength="5" />
<div my-messages="vm.lightsaberForm.fullName"></div>
</div>
</form>
</div>
<hr />
<strong class="title">Model State</strong>
<div ng-if="!vm.showInternalVal">
vm.user.fullName: <span ng-bind="vm.user.fullName"></span>
</div>
<div ng-if="vm.showInternalVal">
<div>
vm.user.fullName:
<span ng-bind="vm.user.fullName()"></span>
(getter/setter, must be invoked to get the value)
</div>
<div>
vm.internalVal: <span ng-bind="vm.internalVal"></span>
</div>
</div>
<hr />
<strong class="title">Field ngModelController</strong>
<pre>{{vm.getImportantStuff(vm.lightsaberForm.fullName) | json}}</pre>
<hr />
<small>
Demo created by Kent C. Dodds
for <a href="http://www.ng-conf.org/">ng-conf 2015</a>.
<br />
If you want to get serious about forms, use
<a href="http://formly-js.github.io/angular-formly">angular-formly</a>
</small>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.4/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.4/angular-aria.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.4/angular-animate.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.0-beta.4/angular-messages.js"></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. |