Can you use Angular routeProvider with Salesforce? I am having trouble rendering views that are located in the static resources zip. Would it be better to use UI Router?

1 Answer 1


The approach to handling static resources in the IssuesInGitHub sample application is to reference the templates using:

templateUrl: '/resource/' + Date.now() + '/github_issues_html'

which ensures that the latest version of the static resource is referenced but stops the template being cached. The approach works fine with $routeProvider. So it is a good approach to start with.

With a bit more effort, if say the index page is a Visualforce page, you can set a field of a JavaScript object to the Visualforce expression '{!$Resource.appzip}' and add that object as an Angular constant that you can then reference in the templateUrl:

templateUrl: Constants.zipPrefix + '/github_issues_html'

This ensures that the template static resources are cached and when a new version of the zip is deployed that the new version is moved to and cached.

  • what are your thoughts on using UI-Router to render states as pages? This seem like it would be nice since it does not matter if I am routing through the URL
    – WesW
    Oct 19, 2015 at 22:01
  • 1
    @WesW I've no experience of UI-Router so am not in a position to compare the two. For the Angular code I've written $routeProvider has worked OK. If you need UI-router use it but otherwise KISS.
    – Keith C
    Oct 19, 2015 at 23:03
  • The example you referred to is using UI router instead of the standard routeProvider
    – WesW
    Oct 20, 2015 at 3:01
  • @WesW Sure but AFAIK the templateUrl concept is the same.
    – Keith C
    Oct 20, 2015 at 7:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .