- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我被困住了“无法绑定(bind)到‘ngModule’,因为它不是‘select’的已知属性。”错误。该解决方案应该是在 app.module.shared.ts 文件中导入 FormsModule。我做了,但我仍然遇到同样的错误。
app.module.shared.t
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app/app.component';
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { StatisticComponent} from './components/statistic/statistic.component';
import { StatisticViewComponent } from './components/statisticview/statisticview.component';
import { StatService } from './components/services/stat.service';
@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
HomeComponent,
StatisticComponent,
StatisticViewComponent
],
imports: [
FormsModule,
CommonModule,
HttpModule,
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'statistic', component: StatisticComponent },
{ path: 'statisticview', component: StatisticViewComponent },
{ path: '**', redirectTo: 'home' }
])
],
providers: [
StatService
]
})
export class AppModuleShared {
}
statisticview.component.ts
import { StatService } from './../services/stat.service';
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-statistic-view',
templateUrl: './statisticview.component.html',
styleUrls: ['./statisticview.component.css']
})
export class StatisticViewComponent implements OnInit {
private affiliates:string[]
selectedAffiliate: any;
constructor(private statService: StatService) {
}
ngOnInit(): void {
this.statService.getAvailableAffiliates().subscribe( s => {
this.affiliates = s;
console.log(s);
})
}
OnAffiliateChange() {
console.log(this.selectedAffiliate)
}
}
statisticview.component.html
<div class="row">
<div class="form-group">
<label for="aff">Affiliate</label>
<select name="aff" id="aff" class="form-control" (change)="OnAffiliateChange()" [(ngModule)] ="selectedAffiliate">
<option value=""></option>
<option *ngFor="let a of affiliates" value="{{a}}">{{a}}</option>
</select>
</div>
</div>
来自 package.json
"dependencies": {
"@angular/animations": "4.2.5",
"@angular/common": "4.2.5",
"@angular/compiler": "4.2.5",
"@angular/compiler-cli": "4.2.5",
"@angular/core": "4.2.5",
"@angular/forms": "4.2.5",
"@angular/http": "4.2.5",
"@angular/platform-browser": "4.2.5",
........
最佳答案
应该是 ngModel
而不是 NgModule
<select name="aff" id="aff" class="form-control" (change)="OnAffiliateChange()" [(ngModel)] ="selectedAffiliate">
<option value=""></option>
<option *ngFor="let a of affiliates" value="{{a}}">{{a}}</option>
</select>
关于Angular 4。错误 "Can' t 绑定(bind)到 'ngModule',因为它不是“的已知属性”,但 FormsModule 是在 app.module.shared.ts 中导入的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46426206/
它工作得很好,突然它在运行 ng serve 时开始给我下面的异常。我也没有做任何最近的升级或依赖项添加。 有人能帮我解决一下吗? ERROR in Error: NgModule is not an
关注此discussion ,我遇到了同样的问题:我无法在多个模块中导入 angular2-materialize 的指令,而不会出现错误消息“Type X is part of the statem
我想知道是创建一个包含我所有 Angular 2 代码的单个模块更好,还是将所有内容拆分到多个模块更好。例如,我正在使用 Angular 2 创建我的博客。所以我有一个“文章列表”组件和一个“文章”组
我正在关注这个 tutorial拥有我的应用程序的架构。 要提供更多信息,请考虑 A作为 appModule,和 B是另一个主要模块。现在我想在 B 的 NgModule 中加载其他模块( 有许多其
我正在尝试此链接中的所有解决方案: https://stack247.wordpress.com/2018/09/07/angular-all-possible-solutions-for-no-ng
当我使用 CLI 创建新组件时,我在这篇文章的主题中遇到错误:ng g c my-component --project=my-project(没有创建组件) 我看过其他帖子有相同的错误消息,但没有一
ERROR in node_modules/@angular/material/dialog/dialog.d.ts:142:22 -error NG6002: Appears in the NgMo
我刚刚从 Angular 8.2 更新到 9。 如果我禁用 ivy 一切正常,但是当它启用时,我收到了很多似乎有点模糊的错误,至少我在谷歌搜索时找不到任何结果。 我很确定我已经完成了更新所需的一切,即
第一次使用firestore,我收到了这个错误。根据我的研究,这似乎是 Ivy 的问题。我没有很多修改 tsconfig.app.json 的经验,这是我被指出的方向,遵循其他答案。 我能够从原始项目
您好,我刚刚使用简单的 CLI 从 CLI 创建了一个新项目 ng new frontend 一旦我进入我的项目,命令: cd frontend/src/app 并尝试像这样生成一个新组件 ng ge
我在应用程序上有三个模块,其中一个是主模块,用于其他两个模块。 当我启动应用程序并直接转到导入主模块的这些模块之一时,浏览器控制台中会显示此错误: core.js:4117 ERROR Error:
我有使用 ngx-translate 中的 TranslateModule 的模块(问题不是关于这个库,而是关于 Angular)。它看起来像这样: @NgModule({ ... impor
我想创建一个与图表相关的模块并将其写在其他地方。 模块声明源码如下。 图表.module.ts import { NgModule, ModuleWithProviders } from '@angu
我正在通过刚买的一本书学习 angular 2(成为 angular 2 的忍者)。 我也在同时浏览官方文档,但是在从官方网站进行快速入门时,我看到他们在谈论 @NgModule 而书中没有提到它。
我有这个 NgModule: @NgModule({ imports: [ CommonModule ], exports: [ SP21Loa
所以我现在正在学习 angular2 并阅读有关模块的 ngbook2。模块包含组件,但也可以导入具有公共(public)组件的不同模块。 问题是:模块组件的范围是什么(在这个范围内是应用程序的一部分
所以我创建了一个组件 示例组件 并在 的模块中声明它不是在 app.module 中列出。 接下来我要声明组件 示例组件 在一个模块中 是 在 app.module 中列出。我该怎么做呢?如果我简单地
我使用 angular 9,我想做延迟加载,我做 app-routing { path: '', loadChildren: () => import("./components/login/
我不明白为什么当我有了新的提供商时,我一次又一次地遇到这个错误。当我有任何其他提供商(如地理定位等)时,我遇到此错误: Error: Uncaught Error: Invalid provider
我有一个 Angular 应用程序,但我不明白编译器告诉我为什么应用程序无法构建的原因。这些是我从编译器收到的错误: ERROR in src/app/list-items/list-items.co
我是一名优秀的程序员,十分优秀!