使用angular 4在垫子表中添加新行 [英] Add a new row into mat-table using angular 4

查看:99
本文介绍了使用angular 4在垫子表中添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从输入字段手动向Angular Material表中添加新行.

How to add a new row into Angular Material table manually from a input field.

请看这张图片,如果我添加一个州名和州代码,它应该显示在下表中,请帮助我如何使用Angular 4实现它.

Please see this image in that if i add a state name and state code it should present in the following table please help me how to achieve it using Angular 4.

推荐答案

我整理了一个简单的示例,该示例应该为您提供从哪里开始的好提示:

I've put together a quick example that should give you a good hint as to where to start from: Working demo

这可以通过在输入字段上使用双向数据绑定来跟踪用户在表单中键入的内容来进行.然后按下add按钮时,将使用由输入内容动态创建的新元素更新表.

This works by using two-way data binding on the input field to keep track of what the user typed in the form. When the add button is then pressed, the table is updated with a new element dynamically created with the input content.

这篇关于使用angular 4在垫子表中添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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