如何访问范围,功能链接功能里面angularjs指令? [英] How to access scope in a function inside link function in angularjs directive?
本文介绍了如何访问范围,功能链接功能里面angularjs指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能不是一个angularJS问题,但我在我束手无策这儿。在code如下所示:
This might not be an angularJS problem but I am at my wit's end here. The code is shown below:
prep.directive('resultgraph', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
//** scope accessible here **
DomReady.ready(function () {
ThreeBox.preload([
'/scripts/lib/snippets.glsl.html',
], function () {
//....scope not accessible here
如何访问的'preLOAD,它说:范围无法访问这里的回调函数内的范围?
How do I access the scope inside the callback function of 'preload', where it says scope is not accessible here ?
推荐答案
如果你需要的DOM准备就绪,你可以做此链接函数内(范围将访问):
If you need the DOM to be ready you can do this inside the link function (the scope will be accessible):
$timeout(function(){
alert('DOM ready');
//** scope accessible here **
});
这篇关于如何访问范围,功能链接功能里面angularjs指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文