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
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– WesWOct 19, 2015 at 22:01
-
1
-
The example you referred to is using UI router instead of the standard routeProvider– WesWOct 20, 2015 at 3:01
-