mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-09 17:10:34 +08:00
docs(formDirective): update example to use a module
This commit is contained in:
@@ -314,12 +314,13 @@ function FormController(element, attrs, $scope, $animate) {
|
||||
* </pre>
|
||||
*
|
||||
* @example
|
||||
<example deps="angular-animate.js" animations="true" fixBase="true">
|
||||
<example deps="angular-animate.js" animations="true" fixBase="true" module="formExample">
|
||||
<file name="index.html">
|
||||
<script>
|
||||
function Ctrl($scope) {
|
||||
$scope.userType = 'guest';
|
||||
}
|
||||
angular.module('formExample', [])
|
||||
.controller('FormController', ['$scope', function($scope) {
|
||||
$scope.userType = 'guest';
|
||||
}]);
|
||||
</script>
|
||||
<style>
|
||||
.my-form {
|
||||
@@ -331,7 +332,7 @@ function FormController(element, attrs, $scope, $animate) {
|
||||
background: red;
|
||||
}
|
||||
</style>
|
||||
<form name="myForm" ng-controller="Ctrl" class="my-form">
|
||||
<form name="myForm" ng-controller="FormController" class="my-form">
|
||||
userType: <input name="input" ng-model="userType" required>
|
||||
<span class="error" ng-show="myForm.input.$error.required">Required!</span><br>
|
||||
<tt>userType = {{userType}}</tt><br>
|
||||
|
||||
Reference in New Issue
Block a user