mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-21 15:14:44 +00:00
docs(guide/$location): fix broken example demo
The demo of the hash-bang vs html5-mode deep links was broken since the introduction
of a check for previously bootstrapped elements. See this commit: 3ee744cc63
We fix this problem by applying a null for the injector value of the element of the
at the root of the sub-app.
It also turns out that it was not necessary, and if fact broke the demo, to replace
the $document service for the sub-app. This was because the $compile service calls
`$document.createElement()`, which doesn't exist on a `div`.
Finally, the bootstrap CSS was limiting the width of the ngAddress bar input box,
which made it difficult to see the changing URLs.
This commit is contained in:
parent
a005797afa
commit
2e5680a4e3
1 changed files with 4 additions and 2 deletions
|
|
@ -447,17 +447,19 @@ In this examples we use `<base href="/base/index.html" />`
|
|||
|
||||
function initEnv(name) {
|
||||
var root = angular.element(document.getElementById(name + '-mode'));
|
||||
// We must kill a link to the injector for this element otherwise angular will
|
||||
// complain that it has been bootstrapped already.
|
||||
root.data('$injector', null);
|
||||
angular.bootstrap(root, [function($compileProvider, $locationProvider, $provide){
|
||||
$locationProvider.html5Mode(true).hashPrefix('!');
|
||||
|
||||
$provide.value('$browser', browsers[name]);
|
||||
$provide.value('$document', root);
|
||||
$provide.value('$sniffer', {history: name == 'html5'});
|
||||
|
||||
$compileProvider.directive('ngAddressBar', function() {
|
||||
return function(scope, elm, attrs) {
|
||||
var browser = browsers[attrs.browser],
|
||||
input = angular.element('<input type="text">').val(browser.url()),
|
||||
input = angular.element('<input type="text" style="width: 400px">').val(browser.url()),
|
||||
delay;
|
||||
|
||||
input.on('keypress keyup keydown', function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue