Identifier Conflict due to $window.DISQUS never initialized (Lazy Loading Needed)
Followed all your code but still get an identifier conflict (same comments across multiple articles on blog) and get this error in console:
angular.js:13550TypeError: Cannot read property 'reset' of undefined
Traced it to $window.DISQUS.reset()
$window.DISQUS never gets initialized even though I have the script tag created and appended to the document. Seems like $window.DISQUS is not defined even though it is created and appended to the document. I tried modulating it more in code and creating the script tag before calling reset function that you define.
I believe an easy fix maybe in lazy loading the script creation within a promise. I am trying it out now, but if someone has had a similar problem or knows my problem please let me know so I am not wasting my time.
I have not included my code because I have greatly changed it from michaelbromley's code to try and find and fix the issue.
Hi,
Sounds weird. reset() is only called in a single place:
if (!$window.DISQUS) {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + scope.config.disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
} else {
$window.DISQUS.reset({
reload: true,
// etc.
});
}
So I am wondering how it is at all possible that execution could reach that else branch if $window.DISQUS === undefined. There is some information I am lacking here - let me know what you find out in your debugging.
yeah I tried other modules and I just can't get disqus and angular-js to work correctly. I am going to retry this project and report back because I am sure I am going to have the same problem again. (sorry just got a new laptop so this is pretty late response. Just want to let you know this is still being worked on in some way)