NG-重复数据自定义指令绑定 [英] ng-repeat data binding with custom directive
问题描述
我有一个列表,在列表中的每个项目我打电话模态窗口被点击(自定义指令)应该具备哪些有关该项目的详细信息,但数据并没有改变,仍然在每一个项目相同。请看以下code。
I have a list and on each item in list I am calling a modal window (custom directive) which should have details about that item being clicked , but the data does not change and remains same across each item. Please find the code below.
angular
.module('Testapp')
.directive('testDirective', function () {
return {
restrict: "AE",
templateUrl: "/Apps/templates/mytem/testdir.html",
translucent: true,
scope: {item:'=data'},
link: function (scope, element, attribute) {
console.log(scope.sequence);
}
};
});
指令
<div class="modal fade" id="modalAddFilters">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body tree">
{{item}}
</div>
</div>
</div>
</div>
调用模板
<div>
<div ng-repeat="items in TestList>
<test-Directive id="directive_modalAddFilters" data="items"></test-Directive>
</div>
我能看到的数据正确装入DOM ,但指令模板并没有改变的数据。
I am able to see the data correctly loaded in DOM but directive template doesnt change the data.
推荐答案
您code正常工作,但您忘记关闭您 NG-重复
带引号。
You code works fine, except that you forget to close you ng-repeat
with a quotation mark.
我觉得你只是没有妥善解决你的数据到模态的视图。
I think you just didn't properly resolved you data into the modal view.
我已经做了普拉克 $ C,我加了一个模式,一切工作正常。我用UI的引导,以显示注射重复数据模式。
I have made a plunk based on your (partial) code, I added a modal and everything works fine. I've used ui-bootstrap to show the modal with the repeated data injected.
这篇关于NG-重复数据自定义指令绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!