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

$location service not compatible with 'turbolinks' (Ruby on Rails) #6638

Closed
@asgeo1

Description

@asgeo1

I've been using AngularJS (v1.2.14) with a Ruby on Rails app, which has turbolinks turned on. It's been working great and I haven't had any issues (up until now).

I notice now though there is an issue when including the $location service. Simply importing this service into directive/controller/service will cause a JS error when clicking the browser's back button:

TypeError: Cannot call method 'charAt' of undefined
    at Object.LocationHashbangUrl.$$parse (http://test.delman.dev/assets/angular.js?body=1:8839:41)
    at http://test.delman.dev/assets/angular.js?body=1:9318:21
    at Scope.$eval (http://test.delman.dev/assets/angular.js?body=1:12076:28)
    at Scope.$digest (http://test.delman.dev/assets/angular.js?body=1:11904:31)
    at http://test.delman.dev/assets/angular.js?body=1:9327:45
    at http://test.delman.dev/assets/angular.js?body=1:4336:7
    at Array.forEach (native)
    at forEach (http://test.delman.dev/assets/angular.js?body=1:323:11)
    at fireUrlChange (http://test.delman.dev/assets/angular.js?body=1:4335:5)
    at jQuery.event.dispatch (http://test.delman.dev/assets/jquery.js?body=1:3075:9) 

I guess I could just avoid the $location service... the problem is some 3rd party libraries (i.e. angular-strap) are including it.

Not ruling out this being a turbolinks issue either - I'm not really sure what's causing the error in the AngularJS internals

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions