Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Angular.js 1.3-rc0 HTML5 Location and base tags #8866

Closed
billxinli opened this issue Aug 30, 2014 · 11 comments
Closed

Angular.js 1.3-rc0 HTML5 Location and base tags #8866

billxinli opened this issue Aug 30, 2014 · 11 comments

Comments

@billxinli
Copy link

Recently bumped Angular.js to latest 1.3-rc0 release.

Project is using ui-router with HTML5 location mode set to true.

Added the <base> tag inside of the <html> tag. Like so:

<head>
  <base href="/">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <link href='/css/vendor.css' type='text/css' media='all' rel='stylesheet'>
  <link href='/css/application.css' type='text/css' media='all' rel='stylesheet'>
  <script src="/js/vendor.js" type="text/javascript"></script>
  <script src="/js/templatescache.js" type="text/javascript"></script>
</head>

The routing is defined as:

  $locationProvider.html5Mode(true)
  $urlRouterProvider.otherwise('/')
  $stateProvider....

However, in Karma test I am seeing:

  Error: [$location:nobase] $location in HTML5 mode requires a <base> tag to be present!
  http://errors.angularjs.org/1.3.0-rc.0/$location/nobase
      at /code/project/public/js/vendor.js:57677
      at invoke (/code/project/public/js/vendor.js:51462)
      at /code/project/public/js/vendor.js:51294
      at getService (/code/project/public/js/vendor.js:51421)
      at invoke (/code/project/public/js/vendor.js:51453)
      at /code/project/public/js/vendor.js:51294
      at getService (/code/project/public/js/vendor.js:51421)
      at invoke (/code/project/public/js/vendor.js:51453)
      at /code/project/public/js/vendor.js:51294
      at getService (/code/project/public/js/vendor.js:51421)
      at invoke (/code/project/public/js/vendor.js:51453)
      at /code/project/public/js/vendor.js:51298
      at forEach (/code/project/public/js/vendor.js:47695)
      at createInjector (/code/project/public/js/vendor.js:51298)
      at workFn (/code/project/bower_components/angular-mocks/angular-mocks.js:2226)
PhantomJS 1.9.7 (Mac OS X): Executed 9 of 47 (9 FAILED) ERROR (0.016 secs / 0.078 secs)
@IgorMinar
Copy link
Contributor

@tbosch, I think that we need to make sure that the mock has a default base url set to /

@IgorMinar IgorMinar added this to the 1.3.0-rc.1 milestone Aug 30, 2014
@caitp caitp closed this as completed Sep 2, 2014
@caitp caitp reopened this Sep 2, 2014
@caitp
Copy link
Contributor

caitp commented Sep 2, 2014

accident! carry on.

@tbosch
Copy link
Contributor

tbosch commented Sep 2, 2014

Yes, will work on this today

tbosch added a commit to tbosch/angular.js that referenced this issue Sep 2, 2014
Set the default value for the base tag in the mock browser to `/`,
as we now always require a base tag to be present for html5 mode.

Fixes angular#8866.
@tbosch tbosch closed this as completed in fc706d1 Sep 2, 2014
@tysonnero
Copy link

I've upgraded to v1.3.0-rc.1, however I am still seeing the exact same issue as @billxinli.

@caitp
Copy link
Contributor

caitp commented Sep 12, 2014

@tysonnero did you upgrade both angular-mocks and angular? (a frequent occurrence lately seems to be people reporting bugs caused by using mismatched versions of angular-mocks and angular, which is why I ask)

@ghoullier
Copy link

I'v the same problem as @tysonnero and @billxinli. Reproduced with rc-0 and rc-1, not reproduced in beta-19.

@tysonnero
Copy link

@caitp - I did upgrade angular, angular-mocks, and all other angular libs. I opened each file to double check the version was 1.3.0-rc.1. I retried the upgrade this morning on a different box to no avail. But perhaps I'm doing something wrong.

@billxinli
Copy link
Author

When the Angular.js team fixed the mock location issue, we just bumped angular-mock to master.

"angular-mocks": "git@github.com:twg/bower-angular-mocks.git#master"

which made all of our tests passing again.

@Awk34
Copy link

Awk34 commented Nov 12, 2014

Thanks guys, I had the same issue, forgot to bump angular-mocks to 1.3

@johnpapa
Copy link
Contributor

appears to be fixed in 1.2.26, too. thanks

@bperel
Copy link

bperel commented Jun 15, 2015

I don't see this fixed on 1.2.x : angular-mocks.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants