angularUtils icon indicating copy to clipboard operation
angularUtils copied to clipboard

dirDisqus: prevent error when config object is undefined

Open niklanus opened this issue 9 years ago • 1 comments

I ran into this error TypeError: Cannot read property 'disqus_shortname' of undefined when using a config object that got their data asynchronously, in my WP REST API + AngularJS front-end blog.

Template: <dir-disqus config="disqusConfig"></dir-disqus>

Controller:

afterSomeAjaxStuff(function(){
    $scope.disqusConfig = {
        disqus_shortname: 'myShortname',
        disqus_identifier: $stateParams.slug,
        disqus_url: $scope.currentURL
    };
});

This is just a simple flag to check that the config object actually has some data before continuing to execute the rest of configChanged().

niklanus avatar Apr 30 '16 20:04 niklanus

:+1:

Hacksore avatar Jun 12 '16 18:06 Hacksore