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

Skip to content

Commit 3b5f346

Browse files
committed
docs(ngSubmit): update example to use a module
1 parent 3aab87b commit 3b5f346

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/ng/directive/ngEventDirs.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,22 @@ forEach(
313313
* ({@link guide/expression#-event- Event object is available as `$event`})
314314
*
315315
* @example
316-
<example>
316+
<example module="submitExample">
317317
<file name="index.html">
318318
<script>
319-
function Ctrl($scope) {
320-
$scope.list = [];
321-
$scope.text = 'hello';
322-
$scope.submit = function() {
323-
if ($scope.text) {
324-
$scope.list.push(this.text);
325-
$scope.text = '';
326-
}
327-
};
328-
}
319+
angular.module('submitExample', [])
320+
.controller('ExampleController', ['$scope', function($scope) {
321+
$scope.list = [];
322+
$scope.text = 'hello';
323+
$scope.submit = function() {
324+
if ($scope.text) {
325+
$scope.list.push(this.text);
326+
$scope.text = '';
327+
}
328+
};
329+
}]);
329330
</script>
330-
<form ng-submit="submit()" ng-controller="Ctrl">
331+
<form ng-submit="submit()" ng-controller="ExampleController">
331332
Enter text and hit enter:
332333
<input type="text" ng-model="text" name="text" />
333334
<input type="submit" id="submit" value="Submit" />

0 commit comments

Comments
 (0)