I've this widget code inside directive html template.
<script type="text/javascript">
_hcwp = window._hcwp || [];
_hcwp.push({widget:"Stream", widget_id:10862, xid:{{_id}});
(function() {
if("HC_LOAD_INIT" in window)return;
HC_LOAD_INIT = true;
var lang = (navigator.language || navigator.systemLanguage || navigator.userLanguage || "en").substr(0, 2).toLowerCase();
var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://w.hypercomments.com/widget/hc/10862/"+lang+"/widget.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hcc, s.nextSibling);
})();
Inside this template have a variable {{_id}}.
But when angular render this template, variable is not sent inside template.
At some point have to send a variable inside temple for render?
My directives:
app.directive('hyperComments', function($timeout) {
return {
restrict: 'E',
templateUrl: './templates/hc.html',
replace: true,
scope: {
xid: '='
},
link: function(scope, element, attrs) {
console.log('hello!');
$timeout(function() {
_hcwp = window._hcwp || [];
_hcwp[0]= { widget:"Stream", widget_id: 28172, xid: 31241123};
// HC.widget("Stream", _hcwp);
(function() {
// if("HC_LOAD_INIT" in window)return;
// var HC_LOAD_INIT = true;
console.log('in');
var lang = (navigator.language || navigator.systemLanguage || navigator.userLanguage || "en").substr(0, 2).toLowerCase();
var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;
hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://w.hypercomments.com/widget/hc/9345/"+lang+"/widget.js";
var s = document.getElementsByTagName("script")[0];
console.log(s);
s.parentNode.insertBefore(hcc, s.nextSibling);
})();
}, 10000);
}
};
});
Template:
< div> < div id="hypercomments_widget"> comments powered by HyperComments < /div>