我在controller.js下面有代码,在这里我得到了“postresult”值。
$scope.open= function(post) {
$scope.postresult = post;
}
在下面的HTML代码中,我正在加载DISQUS线程,我需要访问“postresult”对象,我该怎么做?
<script type="text/javascript">
var pid = '{{postresult.id}}';
var pid1 = 'postresult.id';
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'a2b'; // required: replace example with your forum shortname
var disqus_identifier = '{{postresult.id}}' ;
var disqus_title = '{{postresult.postText}}';
var disqus_url = 'http://pingle.com:8080/ngdemo/{{postresult.id}}';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
var reset = function (postresult.id, http://pingle.com:8080/ngdemo/{{postresult.id}}, postresult.postText, en) {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = newIdentifier;
this.page.url = newUrl;
this.page.title = newTitle;
this.language = newLanguage;
}
});
};
</script>
答案 0 :(得分:0)
您可以使用$window
服务
app.controller('MainCtrl', function($scope, $window) {
$window.postresult = 0;
$scope.change = function() {
$window.postresult++;
}
});
然后您可以通过window.postresult
window.setInterval(function() {
window.$('#output').text(window.postresult);
},100);