Open bsouthga opened 8 years ago
added the option for manually injecting the zendesk lib in this branch: https://github.com/CrossLead/angular-zendesk-widget/tree/dynamic-loading
Now, if the plugin is configured as such:
angular.module('myApp')
.config(['ZendeskWidgetProvider', function(ZendeskWidgetProvider) {
ZendeskWidgetProvider.init({
manual: true
});
}]);
You can trigger the injection of the library at a later point like:
angular.module('myApp')
.controller('main', ['$rootScope', 'ZendeskWidget', function($rootScope, ZendeskWidget) {
ZendeskWidget.settings({
accountUrl: $rootScope.currentUser.accountUrl
});
// idempotent, so can call multiple times with no further effect
ZendeskWidget.injectZendeskScript();
}]);
To allow for injecting the script with an accountUrl that is retrieved from somewhere in the app unreachable via a .config()
statement
Not sure how we can make this happen as the url is required when the script is injected, but there might be a way to move the script injection into a run statement (instead of a config)...