aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorVojta Jina2011-07-12 02:18:46 +0200
committerVojta Jina2011-09-08 23:00:59 +0200
commit4421f3d43525437bd939f647604480c1ed126e5e (patch)
treeb27657098ccf4395827871533ba8bb2b5a90e7fc /docs
parent22cb600280cecabf719ba1878719c907aa01ba18 (diff)
downloadangular.js-4421f3d43525437bd939f647604480c1ed126e5e.tar.bz2
fix(docs): update docs to reflect new $location and fix e2e tests
Diffstat (limited to 'docs')
-rw-r--r--docs/content/cookbook/deeplinking.ngdoc10
-rw-r--r--docs/content/cookbook/mvc.ngdoc6
-rw-r--r--docs/src/templates/docs.js26
3 files changed, 25 insertions, 17 deletions
diff --git a/docs/content/cookbook/deeplinking.ngdoc b/docs/content/cookbook/deeplinking.ngdoc
index e49287bb..10c80f21 100644
--- a/docs/content/cookbook/deeplinking.ngdoc
+++ b/docs/content/cookbook/deeplinking.ngdoc
@@ -43,7 +43,7 @@ The two partials are defined in the following URLs:
AppCntl.$inject = ['$route']
function AppCntl($route) {
// define routes
- $route.when("", {template:'./examples/welcome.html', controller:WelcomeCntl});
+ $route.when("/welcome", {template:'./examples/welcome.html', controller:WelcomeCntl});
$route.when("/settings", {template:'./examples/settings.html', controller:SettingsCntl});
$route.parent(this);
@@ -61,7 +61,9 @@ The two partials are defined in the following URLs:
}
};
- function SettingsCntl(){
+ SettingsCntl.$inject = ['$location'];
+ function SettingsCntl($location){
+ this.$location = $location;
this.cancel();
}
SettingsCntl.prototype = {
@@ -71,13 +73,13 @@ The two partials are defined in the following URLs:
save: function(){
angular.copy(this.form, this.person);
- window.location.hash = "#";
+ this.$location.path('/welcome');
}
};
</script>
<div ng:controller="AppCntl">
<h1>Your App Chrome</h1>
- [ <a href="#">Welcome</a> | <a href="#/settings">Settings</a> ]
+ [ <a href="#!/welcome">Welcome</a> | <a href="#!/settings">Settings</a> ]
<hr/>
<span style="background-color: blue; color: white; padding: 3px;">
Partial: {{$route.current.template}}
diff --git a/docs/content/cookbook/mvc.ngdoc b/docs/content/cookbook/mvc.ngdoc
index d757baff..4529cd29 100644
--- a/docs/content/cookbook/mvc.ngdoc
+++ b/docs/content/cookbook/mvc.ngdoc
@@ -26,7 +26,7 @@ no connection between the controller and the view.
'cursor': 'pointer'
};
this.reset();
- this.$watch('$location.hashSearch.board', this.readUrl);
+ this.$watch('$location.search().board', this.readUrl);
}
TicTacToeCntl.prototype = {
dropPiece: function(row, col) {
@@ -62,7 +62,7 @@ no connection between the controller and the view.
angular.forEach(this.board, function(row){
rows.push(row.join(','));
});
- this.$location.hashSearch.board = rows.join(';') + '/' + this.nextMove;
+ this.$location.search({board: rows.join(';') + '/' + this.nextMove});
},
readUrl: function(scope, value) {
if (value) {
@@ -72,8 +72,6 @@ no connection between the controller and the view.
this.board[col] = row.split(',');
}, this);
this.grade();
- } else {
- this.reset();
}
}
};
diff --git a/docs/src/templates/docs.js b/docs/src/templates/docs.js
index b31a748d..d1069a77 100644
--- a/docs/src/templates/docs.js
+++ b/docs/src/templates/docs.js
@@ -4,7 +4,7 @@ function DocsController($location, $browser, $window, $cookies) {
var self = this,
OFFLINE_COOKIE_NAME = 'ng-offline',
- HAS_HASH = /#/;
+ DOCS_PATH = /^\/(api)|(guide)|(cookbook)|(misc)|(tutorial)/;
this.$location = $location;
@@ -13,13 +13,14 @@ function DocsController($location, $browser, $window, $cookies) {
self.subpage = false;
self.offlineEnabled = ($cookies[OFFLINE_COOKIE_NAME] == angular.version.full);
- if (!HAS_HASH.test($location.href)) {
- $location.hashPath = '!/api';
+ if (!$location.path()) {
+ $location.path('/api').replace();
}
- this.$watch('$location.hashPath', function(scope, hashPath) {
- if (hashPath.match(/^!/)) {
- var parts = hashPath.substring(1).split('/');
+ this.$watch('$location.path()', function(scope, path) {
+ // ignore non-doc links which are used in examples
+ if (DOCS_PATH.test(path)) {
+ var parts = path.split('/');
self.sectionId = parts[1];
self.partialId = parts[2] || 'index';
self.pages = angular.Array.filter(NG_PAGES, {section:self.sectionId});
@@ -67,13 +68,13 @@ function DocsController($location, $browser, $window, $cookies) {
this.afterPartialLoaded = function() {
SyntaxHighlighter.highlight();
$window.scrollTo(0,0);
- $window._gaq.push(['_trackPageview', $location.hashPath.substr(1)]);
+ $window._gaq.push(['_trackPageview', $location.path()]);
};
this.getFeedbackUrl = function() {
return "mailto:angular@googlegroups.com?" +
- "subject=" + escape("Feedback on " + $location.href) + "&" +
- "body=" + escape("Hi there,\n\nI read " + $location.href + " and wanted to ask ....");
+ "subject=" + escape("Feedback on " + $location.absUrl()) + "&" +
+ "body=" + escape("Hi there,\n\nI read " + $location.absUrl() + " and wanted to ask ....");
};
/** stores a cookie that is used by apache to decide which manifest ot send */
@@ -123,3 +124,10 @@ function TutorialInstructionsCtrl($cookieStore) {
$cookieStore.put('selEnv', id);
};
}
+
+angular.service('$locationConfig', function() {
+ return {
+ html5Mode: false,
+ hashPrefix: '!'
+ };
+});