Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for account url to change after loading #3

Open
bsouthga opened this issue Jun 1, 2016 · 2 comments
Open

Allow for account url to change after loading #3

bsouthga opened this issue Jun 1, 2016 · 2 comments

Comments

@bsouthga
Copy link
Contributor

bsouthga commented Jun 1, 2016

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)...

@bsouthga
Copy link
Contributor Author

bsouthga commented Jun 6, 2016

added the option for manually injecting the zendesk lib in this branch: https://github.com/CrossLead/angular-zendesk-widget/tree/dynamic-loading

@bsouthga
Copy link
Contributor Author

bsouthga commented Jun 6, 2016

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

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

No branches or pull requests

1 participant