aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVojta Jina2011-07-12 02:18:46 +0200
committerVojta Jina2011-09-08 23:00:59 +0200
commit4421f3d43525437bd939f647604480c1ed126e5e (patch)
treeb27657098ccf4395827871533ba8bb2b5a90e7fc
parent22cb600280cecabf719ba1878719c907aa01ba18 (diff)
downloadangular.js-4421f3d43525437bd939f647604480c1ed126e5e.tar.bz2
fix(docs): update docs to reflect new $location and fix e2e tests
-rw-r--r--docs/content/cookbook/deeplinking.ngdoc10
-rw-r--r--docs/content/cookbook/mvc.ngdoc6
-rw-r--r--docs/src/templates/docs.js26
-rw-r--r--src/markups.js12
-rw-r--r--src/widgets.js6
5 files changed, 34 insertions, 26 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: '!'
+ };
+});
diff --git a/src/markups.js b/src/markups.js
index 933d91f4..d3af25b4 100644
--- a/src/markups.js
+++ b/src/markups.js
@@ -166,10 +166,10 @@ angularTextMarkup('option', function(text, textNode, parentElement){
<input name="value" /><br />
<a id="link-1" href ng:click="value = 1">link 1</a> (link, don't reload)<br />
<a id="link-2" href="" ng:click="value = 2">link 2</a> (link, don't reload)<br />
- <a id="link-3" ng:href="#{{'123'}}" ng:click="value = 3">link 3</a> (link, reload!)<br />
+ <a id="link-3" ng:href="#!/{{'123'}}" ng:click="value = 3">link 3</a> (link, reload!)<br />
<a id="link-4" href="" name="xx" ng:click="value = 4">anchor</a> (link, don't reload)<br />
<a id="link-5" name="xxx" ng:click="value = 5">anchor</a> (no link)<br />
- <a id="link-6" ng:href="#/{{value}}">link</a> (link, change hash)
+ <a id="link-6" ng:href="#!/{{value}}">link</a> (link, change hash)
</doc:source>
<doc:scenario>
it('should execute ng:click but not reload when href without value', function() {
@@ -187,8 +187,8 @@ angularTextMarkup('option', function(text, textNode, parentElement){
it('should execute ng:click and change url when ng:href specified', function() {
element('#link-3').click();
expect(input('value').val()).toEqual('3');
- expect(element('#link-3').attr('href')).toBe("#123");
- expect(browser().location().hash()).toEqual('123');
+ expect(element('#link-3').attr('href')).toBe("#!/123");
+ expect(browser().location().hash()).toEqual('!/123');
});
it('should execute ng:click but not reload when href empty string and name specified', function() {
@@ -206,8 +206,8 @@ angularTextMarkup('option', function(text, textNode, parentElement){
it('should only change url when only ng:href', function() {
input('value').enter('6');
element('#link-6').click();
- expect(browser().location().hash()).toEqual('/6');
- expect(element('#link-6').attr('href')).toBe("#/6");
+ expect(browser().location().hash()).toEqual('!/6');
+ expect(element('#link-6').attr('href')).toBe("#!/6");
});
</doc:scenario>
</doc:example>
diff --git a/src/widgets.js b/src/widgets.js
index 254331c0..b0430b95 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -1391,9 +1391,9 @@ angularWidget("@ng:non-bindable", noop);
function OverviewCtrl(){}
</script>
<div ng:controller="MyCtrl">
- <a href="#/overview">overview</a> |
- <a href="#/bootstrap">bootstrap</a> |
- <a href="#/undefined">undefined</a>
+ <a href="#!/overview">overview</a> |
+ <a href="#!/bootstrap">bootstrap</a> |
+ <a href="#!/undefined">undefined</a>
<br/>