× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Always put AngularJS form bindings in a model object

Jessamyn Smith
Oct 02, 2015
<p>In AngularJS, you can bind form elements to a data model, something like this.</p> <p>Controller:</p> <p><code>$scope.formData = { date = today(); };</code></p> <p>View:<br> <code>&lt;input type="text" date-time ng-model="formData.date"&gt;</code></p> <p>Note that we are NOT binding directly to $scope! This is very important: if you bind directly to $scope, the view may not be able to write to the model. You can read more about why <a href="http://jimhoskins.com/2012/12/14/nested-scopes-in-angularjs.html">here</a>.</p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus