Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ef1c352

Browse files
committed
docs(ngModel): update examples to use modules
1 parent a5b6444 commit ef1c352

File tree

1 file changed

+54
-46
lines changed

1 file changed

+54
-46
lines changed

src/ng/directive/input.js

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,16 @@ var inputType = {
3939
* @param {boolean=} [ngTrim=true] If set to false Angular will not automatically trim the input.
4040
*
4141
* @example
42-
<example name="text-input-directive">
42+
<example name="text-input-directive" module="textInputExample">
4343
<file name="index.html">
4444
<script>
45-
function Ctrl($scope) {
46-
$scope.text = 'guest';
47-
$scope.word = /^\s*\w*\s*$/;
48-
}
45+
angular.module('textInputExample', [])
46+
.controller('ExampleController', ['$scope', function($scope) {
47+
$scope.text = 'guest';
48+
$scope.word = /^\s*\w*\s*$/;
49+
}]);
4950
</script>
50-
<form name="myForm" ng-controller="Ctrl">
51+
<form name="myForm" ng-controller="ExampleController">
5152
Single word: <input type="text" name="input" ng-model="text"
5253
ng-pattern="word" required ng-trim="false">
5354
<span class="error" ng-show="myForm.input.$error.required">
@@ -119,14 +120,15 @@ var inputType = {
119120
* interaction with the input element.
120121
*
121122
* @example
122-
<example name="number-input-directive">
123+
<example name="number-input-directive" module="numberExample">
123124
<file name="index.html">
124125
<script>
125-
function Ctrl($scope) {
126-
$scope.value = 12;
127-
}
126+
angular.module('numberExample', [])
127+
.controller('ExampleController', ['$scope', function($scope) {
128+
$scope.value = 12;
129+
}]);
128130
</script>
129-
<form name="myForm" ng-controller="Ctrl">
131+
<form name="myForm" ng-controller="ExampleController">
130132
Number: <input type="number" name="input" ng-model="value"
131133
min="0" max="99" required>
132134
<span class="error" ng-show="myForm.input.$error.required">
@@ -194,14 +196,15 @@ var inputType = {
194196
* interaction with the input element.
195197
*
196198
* @example
197-
<example name="url-input-directive">
199+
<example name="url-input-directive" module="urlExample">
198200
<file name="index.html">
199201
<script>
200-
function Ctrl($scope) {
201-
$scope.text = 'http://google.com';
202-
}
202+
angular.module('urlExample', [])
203+
.controller('ExampleController', ['$scope', function($scope) {
204+
$scope.text = 'http://google.com';
205+
}]);
203206
</script>
204-
<form name="myForm" ng-controller="Ctrl">
207+
<form name="myForm" ng-controller="ExampleController">
205208
URL: <input type="url" name="input" ng-model="text" required>
206209
<span class="error" ng-show="myForm.input.$error.required">
207210
Required!</span>
@@ -270,14 +273,15 @@ var inputType = {
270273
* interaction with the input element.
271274
*
272275
* @example
273-
<example name="email-input-directive">
276+
<example name="email-input-directive" module="emailExample">
274277
<file name="index.html">
275278
<script>
276-
function Ctrl($scope) {
277-
$scope.text = 'me@example.com';
278-
}
279+
angular.module('emailExample', [])
280+
.controller('ExampleController', ['$scope', function($scope) {
281+
$scope.text = 'me@example.com';
282+
}]);
279283
</script>
280-
<form name="myForm" ng-controller="Ctrl">
284+
<form name="myForm" ng-controller="ExampleController">
281285
Email: <input type="email" name="input" ng-model="text" required>
282286
<span class="error" ng-show="myForm.input.$error.required">
283287
Required!</span>
@@ -336,18 +340,19 @@ var inputType = {
336340
* be set when selected.
337341
*
338342
* @example
339-
<example name="radio-input-directive">
343+
<example name="radio-input-directive" module="radioExample">
340344
<file name="index.html">
341345
<script>
342-
function Ctrl($scope) {
343-
$scope.color = 'blue';
344-
$scope.specialValue = {
345-
"id": "12345",
346-
"value": "green"
347-
};
348-
}
346+
angular.module('radioExample', [])
347+
.controller('ExampleController', ['$scope', function($scope) {
348+
$scope.color = 'blue';
349+
$scope.specialValue = {
350+
"id": "12345",
351+
"value": "green"
352+
};
353+
}]);
349354
</script>
350-
<form name="myForm" ng-controller="Ctrl">
355+
<form name="myForm" ng-controller="ExampleController">
351356
<input type="radio" ng-model="color" value="red"> Red <br/>
352357
<input type="radio" ng-model="color" ng-value="specialValue"> Green <br/>
353358
<input type="radio" ng-model="color" value="blue"> Blue <br/>
@@ -386,15 +391,16 @@ var inputType = {
386391
* interaction with the input element.
387392
*
388393
* @example
389-
<example name="checkbox-input-directive">
394+
<example name="checkbox-input-directive" module="checkboxExample">
390395
<file name="index.html">
391396
<script>
392-
function Ctrl($scope) {
393-
$scope.value1 = true;
394-
$scope.value2 = 'YES'
395-
}
397+
angular.module('checkboxExample', [])
398+
.controller('ExampleController', ['$scope', function($scope) {
399+
$scope.value1 = true;
400+
$scope.value2 = 'YES'
401+
}]);
396402
</script>
397-
<form name="myForm" ng-controller="Ctrl">
403+
<form name="myForm" ng-controller="ExampleController">
398404
Value1: <input type="checkbox" ng-model="value1"> <br/>
399405
Value2: <input type="checkbox" ng-model="value2"
400406
ng-true-value="YES" ng-false-value="NO"> <br/>
@@ -794,14 +800,15 @@ function checkboxInputType(scope, element, attr, ctrl) {
794800
* interaction with the input element.
795801
*
796802
* @example
797-
<example name="input-directive">
803+
<example name="input-directive" module="inputExample">
798804
<file name="index.html">
799805
<script>
800-
function Ctrl($scope) {
801-
$scope.user = {name: 'guest', last: 'visitor'};
802-
}
806+
angular.module('inputExample', [])
807+
.controller('ExampleController', ['$scope', function($scope) {
808+
$scope.user = {name: 'guest', last: 'visitor'};
809+
}]);
803810
</script>
804-
<div ng-controller="Ctrl">
811+
<div ng-controller="ExampleController">
805812
<form name="myForm">
806813
User name: <input type="text" name="userName" ng-model="user.name" required>
807814
<span class="error" ng-show="myForm.userName.$error.required">
@@ -1319,12 +1326,13 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
13191326
* </pre>
13201327
*
13211328
* @example
1322-
* <example deps="angular-animate.js" animations="true" fixBase="true">
1329+
* <example deps="angular-animate.js" animations="true" fixBase="true" module="inputExample">
13231330
<file name="index.html">
13241331
<script>
1325-
function Ctrl($scope) {
1326-
$scope.val = '1';
1327-
}
1332+
angular.module('inputExample', [])
1333+
.controller('ExampleController', ['$scope', function($scope) {
1334+
$scope.val = '1';
1335+
}]);
13281336
</script>
13291337
<style>
13301338
.my-input {
@@ -1339,7 +1347,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
13391347
</style>
13401348
Update input to see transitions when valid/invalid.
13411349
Integer is a valid value.
1342-
<form name="testForm" ng-controller="Ctrl">
1350+
<form name="testForm" ng-controller="ExampleController">
13431351
<input ng-model="val" ng-pattern="/^\d+$/" name="anim" class="my-input" />
13441352
</form>
13451353
</file>

0 commit comments

Comments
 (0)