angularUtils
angularUtils copied to clipboard
dirDisqus: prevent error when config object is undefined
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().
:+1: