ng-repeat 与 Angular JS 中的表格和指令 [英] ng-repeat with tables in Angular JS and directives

查看:25
本文介绍了ng-repeat 与 Angular JS 中的表格和指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用带有指令和 ng-repeat 的 Angular 构建一个响应式数据表.我已经设法让 ng-repeat 与表格一起工作:http://jsfiddle.net/raff77/Asb8k/

I am trying to build a responsive data table using Angular with a directive and ng-repeat. I have managed to get the ng-repeat to work with tables: http://jsfiddle.net/raff77/Asb8k/

{}

我现在试图让它与指令一起工作,但 ng-repeat 不起作用.http://jsfiddle.net/raff77/uwGXb/3/

I am now trying to get it to work with a directive and the ng-repeat does not work. http://jsfiddle.net/raff77/uwGXb/3/

{}

有没有办法让 ng-repeat 与您的指令一起工作,或者您是否应该将其构建到您的指令中.请注意,我已经构建了一个解决方案,将行添加为字符串然后添加 html,但我想避免这种情况并以 Angular 的方式做事.

Is there a way to get the ng-repeat to work with your directive or should you build that into your directive. Notice I have built out a solution to add the rows as strings then html but i want to avoid this and do things the Angular way.

推荐答案

当您想将 'td's 放入指令中的表时,AngularJS 中似乎存在一个错误.请参阅此问题 Angular Directive 不评估内部 ng-repeat特别是这个答案:https://stackoverflow.com/a/15755234/669561.https://github.com/angular/angular.js/issues/1459

There seems to be a bug in AngularJS when you want to put 'td's into a table in a directive. See this question Angular Directive Does Not Evaluate Inside ng-repeat and particularly this answer: https://stackoverflow.com/a/15755234/669561. https://github.com/angular/angular.js/issues/1459

我真的不明白,为什么要用指令填充表格.您没有表格的第一种方法似乎工作得很好,我看不到使用指令的任何优势.

And I don't really see, why you want to fill up the table with a directive. Your first approach without the table seems to work perfectly fine and I cannot see any advanteges over using directives.

这篇关于ng-repeat 与 Angular JS 中的表格和指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆