【发布时间】:2016-08-09 12:49:18
【问题描述】:
我正在尝试从服务访问数据,以便可以使用 jQuery 操作 ngRepeated 列表。我无法让link 函数工作。根据我所阅读的内容,我希望在任一
app.directive('myDir', function() {
return {
restrict: 'E',
templateUrl: 'url.html',
link: function(scope, el, attrs) {
//jQuery to manipulate DOM here
}
};
});
或
app.directive('myDir', function() {
return {
restrict: 'E',
templateUrl: 'url.html',
compile: function(scope, el, attrs) {
return {
post: function() {
//jQuery to manipulate DOM here
}
}
}
}
});
但是元素还没有在页面上,所以它不起作用。我错过了什么?
【问题讨论】:
-
这是准确的代码吗?因为你已经合并了返回的对象(指令定义对象)和函数括号。
-
@GregL 不,这很快就被伪了,并且有大量的语法错误。对于那个很抱歉。已更新。
-
你能在链接函数中放一个断点并确认调试器在那里中断吗?另外,你能显示从服务返回的 ng-repeat 和集合变量吗?
标签: javascript jquery angularjs model-view-controller