Angular 2.0.0-rc.3新表格e2e规范 – 无法绑定到’formGroup’,
我刚刚更新了我的应用程序中的所有表单以使用Angular2-rc3的新表单模块,并且我无法在不看模板解析错误的情况下运行规范.
我的表单在应用程序中运行良好,但是当我运行规范时,我看到的错误如下: ERROR: 'Unhandled Promise rejection:','Template parse errors: Can't bind to 'formGroup' since it isn't a known native property 和 ERROR: 'Unhandled Promise rejection:','Template parse errors: Can't bind to 'formControlName' since it isn't a known native property 我还得到关于使用旧表单模块的警告(我实际上并没有在任何地方使用..我在浏览器控制台中没有收到此错误) WARN: ' *It looks like you're using the old forms module. This will be opt-in in the next RC,and will eventually be removed in favor of the new forms module. For more information,see: https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub ' 在将我的应用程序代码迁移到最新的Forms API时,我在本地运行应用程序时在浏览器控制台中看到了这些错误.我能够通过遵循文档并导入正确的指令来修复它们.不幸的是,现在我正在运行测试,这些错误正在我的终端中发生.我还没有找到有关如何将测试迁移到新表单模块的任何资源…任何想法? 解决方法
我有新的表格在RC4上运行完全相同的问题.引导应用程序工作得很好,但是一旦我去运行单元测试,我就遇到了和你一样的问题.
我认为问题的根源在于引导为我们很好地设置了表单,但是在运行单元测试时,我们通常没有引导任何东西. 我的引导程序看起来像这样: ionicBootstrap(ClickerApp,[ disableDeprecatedForms(),provideForms(),Clickers,provide('Storage',{useClass: Storage})] ); 要做到这一点,我必须做两件事: 1:使用beforeEachProviders为我的单元测试中的表单提供与我的bootstrap中相同的表单: let providers = [ disableDeprecatedForms(),provideForms() ] beforeEachProviders(() => providers); 2:将FORM_DIRECTIVES和REACTIVE_FORM_DIRECTIVES添加到我的组件: @Component({ selector: 'clicker-form',templateUrl: 'build/components/clickerForm/clickerForm.html',directives: [Button,Icon,Item,Label,TextInput,FORM_DIRECTIVES,REACTIVE_FORM_DIRECTIVES],}) Original github issue showing working Link to repo with working example of unit tests on new forms (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |