Can't bind to 'formGroup' since it isn't a known property of 'form'
在APP.module.ts中引入FormsModule, ReactiveFormsModule。
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { CoreModule } from './core/core.module';
import { LoginModule } from './login/login.module';
import { AppRoutingModule } from './app.route.module';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
CoreModule,
FormsModule,
ReactiveFormsModule,
LoginModule,
AppRoutingModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
特别注意:在HTML中一定不能用form,随便换一个单词myGroup就行。
[formGroup]="myGroup"
<div class="login-wrap">
<form [formGroup]="myGroup" (ngSubmit)="onSubmit(myGroup,$event)">
<mat-card class="example-card">
<mat-card-header><mat-card-title>登录</mat-card-title></mat-card-header>
<mat-card-content>
<mat-form-field>
<input matInput placeholder="您的email" formControlName="email">
</mat-form-field>
<mat-form-field>
<input matInput placeholder="您的密码" formControlName="password">
</mat-form-field>
</mat-card-content>
<mat-card-actions>
<button mat-raised-button type="submit">登录</button>
</mat-card-actions>
<mat-card-footer>
<p>还没有账户?<a href="#">注册</a></p>
<p>忘记密码?<a href="#">找回</a></p>
</mat-card-footer>
</mat-card>
</form>
<mat-card class="example-card">
<mat-card-header>
<mat-card-title>每日佳句</mat-card-title>
<mat-card-subtitle>满足感是在于不断努力,而不是现有成就。全新努力就会胜利满满。</mat-card-subtitle>
</mat-card-header>
<img mat-card-image src="https://material.angular.io/assets/img/examples/shiba2.jpg" alt="Photo of a Shiba Inu">
<mat-card-content>
<p>
The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan.
A small, agile dog that copes very well with mountainous terrain, the Shiba Inu was originally
bred for hunting.
</p>
</mat-card-content>
</mat-card>
</div>
Can't bind to 'formGroup' since it isn't a known property of 'form'的更多相关文章
- Angular 报错 Can't bind to 'formGroup' since it isn't a known property of 'form'
错误描述 当form表单加FormGroup属性时报错 Can't bind to 'formGroup' since it isn't a known property of 'form' < ...
- ANGULAR6.x - 错误随笔 - Can't bind to 'formGroup'
formGroup:错误 Can't bind to 'formGroup' since it isn't a known property of 'form'. (" 原因: 在使用for ...
- Angular4 - Can't bind to 'ngModel' since it isn't a known property of 'input'.
用[(ngModel)]="xxx"双向绑定,如:控制台报错:Can't bind to 'ngModel' since it isn't a known property of ...
- angular6 Can't bind to 'zzst' since it isn't a known property of
文档: https://angular.io/guide/template-syntax#event-binding The Angular compiler may reject these bin ...
- Angular: Can't bind to 'ngModel' since it isn't a known property of 'input'问题解决
https://blog.csdn.net/h363659487/article/details/78619225 最初使用 [(ngModel)] 做双向绑定时,如果遇见Angular: Can't ...
- Angular - Can't bind to 'ngModel' since it isn't a known property of 'input'.
用[(ngModel)]="xxx"双向绑定,如:控制台报错:Can't bind to 'ngModel' since it isn't a known property of ...
- Can't bind to 'ngModel' since it isn't a known property of 'input'.
angular项目启动报错 Can't bind to 'ngModel' since it isn't a known property of 'input'. 原因:当前module模块未引入 ' ...
- 在懒加载的Ionic工程中使用 ionic2-auto-complete 组件:Can't bind to 'dataProvider' since it isn't a known property of 'ion-auto-complete'
问题描述: 在基于懒加载的Ionic工程中,使用ionic2-auto-complete组件(GitHub地址:https://github.com/kadoshms/ionic2-autocompl ...
- angular 使用ng-zorro的from组件 运行报错
emplate parse errors: Can't bind to 'formGroup' since it isn't a known property of 'form'. 原因:没有导入表单 ...
随机推荐
- .Net数据操作案例
Interface using System.Collections.Generic; using Ddd.Core.Domain.Customers; namespace Ddd.Services. ...
- 68.connect-flash 用法详解 req,flash()
转自:http://yunkus.com/connect-flash-usage/ connect-flash 用法详解 前端工具 2016-10-05 2016-10-05 朝夕熊 11 ...
- 用Nagios监控Sql Server服务器
在Suse 下配置Nagios来监控Ms SQL Server操作演示 本文出自 "李晨光原创技术博客" 博客,谢绝转载!
- C#之用户自定义控件
一.新建用户自定义控件 如下图所示,想通过LED的点击来实现亮和灭使用去控制下位机. LED亮: LED灭: 首先新建一个用户控件类,如下图所示步骤: 在资源中,添加现有文件中加入图片 加入的图片可以 ...
- Myeclipse集成Maven(图文说明)
myeclipse 上安装 Maven3 环境准备: JDK 1.6 Maven 3.2.5 myeclipse 2013 安装 Maven 之前要求先确定你的 JDK 已经安装配置完毕.Maven是 ...
- Hibernate之关于多对多单向关联映射
[Hibernate]之关于多对多单向关联映射 老师和学生,最典型的多对多关联, Teacher和Student.所谓单向意思就是说.老师知道自己的教的是哪些学生而学生不知道是哪些老师教. 也能够这么 ...
- JAVASE学习笔记:第十章 SWing经常使用控件类(二)
7.JComboBox 下拉列表 /* * 初始化下拉列表 */ public void addcomb(){ String[] area = {"山西省&qu ...
- Unix下后门查找{上}
本文出自 "李晨光原创技术博客" 博客,请务必保留此出处http://chenguang.blog.51cto.com/350944/683699
- File Upload with Jersey
package com.toic.rest; import java.io.File; import java.io.FileOutputStream; import java.io.IOExcept ...
- robot framework 使用三:浏览器兼容性自己主动化
robot framework 測试浏览器兼容性 上图中黄色圈的地方默认什么都不写.是firefox浏览器,写上ie就是ie浏览器了 firefox最新版本号即可.ie须要设置: 1. IE选项设置的 ...