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

Skip to content

Commit c646102

Browse files
committed
docs($location): update example to use a module
1 parent 5c23029 commit c646102

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

docs/content/guide/$location.ngdoc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -622,23 +622,24 @@ The Angular's compiler currently does not support two-way binding for methods (s
622622
to the $location object (using {@link input[text] ngModel} directive on an input
623623
field), you will need to specify an extra model property (e.g. `locationPath`) with two {@link ng.$rootScope.Scope#$watch $watchers}
624624
which push $location updates in both directions. For example:
625-
<example>
625+
<example module="locationExample">
626626
<file name="index.html">
627627
<div ng-controller="LocationController">
628628
<input type="text" ng-model="locationPath" />
629629
</div>
630630
</file>
631631
<file name="script.js">
632-
function LocationController($scope, $location) {
633-
$scope.$watch('locationPath', function(path) {
634-
$location.path(path);
635-
});
636-
$scope.$watch(function() {
637-
return $location.path();
638-
}, function(path) {
639-
$scope.locationPath = path;
640-
});
641-
}
632+
angular.module('locationExample', [])
633+
.controller('LocationController', ['$scope', '$location', function ($scope, $location) {
634+
$scope.$watch('locationPath', function(path) {
635+
$location.path(path);
636+
});
637+
$scope.$watch(function() {
638+
return $location.path();
639+
}, function(path) {
640+
$scope.locationPath = path;
641+
});
642+
}]);
642643
</file>
643644
</example>
644645

0 commit comments

Comments
 (0)