aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content')
-rw-r--r--docs/content/guide/dev_guide.services.$location.ngdoc34
1 files changed, 19 insertions, 15 deletions
diff --git a/docs/content/guide/dev_guide.services.$location.ngdoc b/docs/content/guide/dev_guide.services.$location.ngdoc
index 788fe9a7..027a2332 100644
--- a/docs/content/guide/dev_guide.services.$location.ngdoc
+++ b/docs/content/guide/dev_guide.services.$location.ngdoc
@@ -619,21 +619,25 @@ to the $location object (using {@link api/ng.directive:input.text
ngModel} directive on an input field), you will need to specify an extra model property
(e.g. `locationPath`) with two watchers which push $location updates in both directions. For
example:
-<pre>
-<!-- html -->
-<input type="text" ng-model="locationPath" />
-</pre>
-<pre>
-// js - controller
-$scope.$watch('locationPath', function(path) {
- $location.path(path);
-});
-
-$scope.$watch('$location.path()', function(path) {
- scope.locationPath = path;
-});
-</pre>
-
+<example>
+<file name="index.html">
+<div ng-controller="LocationController">
+ <input type="text" ng-model="locationPath" />
+</div>
+</file>
+<file name="script.js">
+function LocationController($scope, $location) {
+ $scope.$watch('locationPath', function(path) {
+ $location.path(path);
+ });
+ $scope.$watch(function() {
+ return $location.path();
+ }, function(path) {
+ $scope.locationPath = path;
+ });
+}
+</file>
+</example>
# Related API