我正在使用angular2使用* ngFor构建动态表,如下所示,但我无法看到数据。我不确定{{x [col]}}是否正确,有什么想法吗?
<tr *ngFor="let x of exportList">
<td *ngFor="let col of cols">
{{x[col]}}
</td>
</tr>
答案 0 :(得分:0)
您需要遍历内循环中的每一行。 尝试:
<tr *ngFor="let rows of exportList">
<td *ngFor="let col of rows">
{{col}}
</td>
</tr>
答案 1 :(得分:0)
[Mon Mar 20 14:19:16.518151 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] mod_wsgi (pid=12272): Target WSGI script '/var/www/html/python/test_app/test_app/wsgi.py' cannot be loaded as Python module.
[Mon Mar 20 14:19:16.518215 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] mod_wsgi (pid=12272): Exception occurred processing WSGI script '/var/www/html/python/test_app/test_app/wsgi.py'.
[Mon Mar 20 14:19:16.518241 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] Traceback (most recent call last):
[Mon Mar 20 14:19:16.518278 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/var/www/html/python/test_app/test_app/wsgi.py", line 17, in <module>
[Mon Mar 20 14:19:16.518351 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] application = get_wsgi_application()
[Mon Mar 20 14:19:16.518366 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Mon Mar 20 14:19:16.518406 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] django.setup(set_prefix=False)
[Mon Mar 20 14:19:16.518421 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 22, in setup
[Mon Mar 20 14:19:16.518462 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Mar 20 14:19:16.518476 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__
[Mon Mar 20 14:19:16.518571 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] self._setup(name)
[Mon Mar 20 14:19:16.518586 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup
[Mon Mar 20 14:19:16.518605 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] self._wrapped = Settings(settings_module)
[Mon Mar 20 14:19:16.518618 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 97, in __init__
[Mon Mar 20 14:19:16.518634 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Mar 20 14:19:16.518648 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Mon Mar 20 14:19:16.518694 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] __import__(name)
[Mon Mar 20 14:19:16.518719 2017] [wsgi:error] [pid 12272:tid 140248747980544] [client 127.0.0.1:50998] ImportError: No module named test_app.settings
你只需要用x替换cols。 exportList包含object.so在x中你将在每个循环中得到一个对象。通过使用object,你可以获取每个字段。