在Angular中,动态生成的Html控件,如果没有name属性并且在ts中要操作Model的内容。就会引发如题的错误。

解决方案两个:

  1. 加上name的属性
  2. 设置ngModelOptions
     
    [ngModelOptions]="{standalone: true}"

 
 

Angular: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as ‘standalone’ in ngModelOptions.的更多相关文章

  1. ASP.NET Core MVC – Form Tag Helpers

    ASP.NET Core Tag Helpers系列目录 ASP.NET Core MVC Tag Helpers 介绍 ASP.NET Core MVC – Caching Tag Helpers ...

  2. angular中ng-model,返回数据,拆分数据,展示,名称相同,重新赋值会有冲突

    本问题出在angular,1.X版本,我用的是1.5的版本: 问题原因: <input type="number" ng-mode="a" /> & ...

  3. [Angular 2] ng-model and ng-for with Select and Option elements

    You can use Select and Option elements in combination with ng-for and ng-model to create mini-forms ...

  4. Angular中ngModel的$render的详解

    在我开始着手ngModel的领域时候,有一个问题很令我纠结,那就是$render()到底是做什么的呢?查了很多资料都只是简单的描述一下,这就令我很纠结了,终于在一个阳光明媚的晚上,我终于解决了这个大问 ...

  5. angular select2 ng-model 取值 ng-change调用方法

    页面: 引入文件 '/select2.css', '/select2-bootstrap.css', '/select2.min.js', '/ui-select2.js' html: <div ...

  6. Angular2 报错 ERROR Error: If ngModel is used within a form tag

    今天写textarea的双向数据绑定报错,错误如图: 错误代码如下: <div class="form-group"> <textarea id="&q ...

  7. Angular JS ng-model对<select>标签无效的情况

    使用场景一: <select ng-if="item.award_type==1" id="award{{$index+1}}" name="X ...

  8. error:Unterminated &lt;form:form tag

    问题:标签不对称 解决:<form:form></form> 改成 <form:form> </form:form> 虽然又是自动补全带来的bug,但还 ...

  9. form(form基础、标签渲染、错误显示 重置信息、form属性、局部钩子、全局钩子)

    form基础 Django中的Form使用时一般有两种功能: 1.生成html标签 2.验证输入内容 要想使用django提供的form,要在views里导入form模块 from django im ...

随机推荐

  1. bzoj 1588: [HNOI2002]营业额统计(splay入门)

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1588 题解:这题如果用普通的bst的话是可以过时间差不多4s左右如果用splay的话是14 ...

  2. codeforces 820 D. Mister B and PR Shifts(思维)

    题目链接:http://codeforces.com/contest/820/problem/D 题意:求.有一种操作 k = 0: shift p1, p2, ... pn, k = 1: shif ...

  3. codeforces 459 E. Pashmak and Graph(dp)

    题目链接:http://codeforces.com/contest/459/problem/E 题意:给出m条边n个点每条边都有权值问如果两边能够相连的条件是边权值是严格递增的话,最长能接几条边. ...

  4. MySQL连接方式小结

    1.   连接方式 1.1  方式1 /usr/local/mysql5./bin/mysql -p 此方法默认采用root@localhost用户登录, 1.2  方式2 /usr/local/my ...

  5. 百度地图WEB端判断用户是否在网格范围内

    在pc端设置商家的配送范围,用户在下单时,根据用户设置的配送地点判断是否在可配送范围内,并给用户相应的提示. 下面说下我的实现思路: 1.用百度地图在PC端设置配送范围,可拖拽选择 2.根据用户设置的 ...

  6. idea解决This file is indented with tabs instead of 4 spaces

    idea上面总是弹出 解决方法: File -> Settings -> Editor -> Code Style -> Java -> Tabs and Indents ...

  7. java 手机号码+邮箱的验证

    import java.util.regex.Pattern; //导入的包 1:String REGEX_MOBILE = "^((17[0-9])|(14[0-9])|(13[0-9]) ...

  8. 常用 JS 函数

    各种业务开发都离不开对数据的处理,然而遇到的很多数据都是不好处理的.这个时候就需要寻求搜索引擎的帮助.这种方法效率是非常低下的,而且根据作者的个性不能保证其对自己的口味.因此这篇文字包含了一份 JS ...

  9. ReactNative之Redux详解

    用redux有一段时间了,感觉还是有必要把其相关的知识点系统的总结一下的,毕竟好记性不如烂笔头.上篇博客更新了关于<ES6中的迭代器.Generator函数以及Generator函数的异步操作& ...

  10. 11-常用SQL总结

    1.设置表的列不能为nullalter table run.dbo.T1 alter column Col1 int not null 2.给表添加主键alter table run.dbo.T1 a ...