Unexpected directive 'XXX' imported by the module 'AppMoode'
做angular demo报错: Uncaught Error: Unexpected directive 'ScrollSpyDirective' imported by the module 'AppModule'. Please add a @NgModule annotation。解决问题时发现对@NgModule中import、declarations、providers这三个配置信息理解不是很到位。特此整理下。
每个模块的@NgModule中都会包含import、declarations、providers三个配置节,他们的具体含义为:
import:当前模块导入的其他模块,import应该导入的是module,而不是compnents或者services
declarations:当前模块内包含的公共组件、指令信息。declarations生命的是components,而不是module或者services
providers:当前模块可以使用的公共服务(可以为本模块内提供的服务,也可以是其他npm包中导入的服务)。provider提供的应该是services,而不是compnents或者modules。
了解了以上信息此问题的原因就很清晰了,ScrollSpyDirective属于本模块内的组件。引入ScrollSpyDirective应该在declarations中生命而不应该在import中引入。
Unexpected directive 'XXX' imported by the module 'AppMoode'的更多相关文章
- Angular4.0 项目报错:Unexpected value xxxComponent' declared by the module 'xxxxModule'. Please add a @Pipe...
最近刚刚开始学习angular 4.0,在网上找了一个小项目教程学习,然而学习的过程有点艰辛,,各种报错,我明明就是按照博主的步骤老老实实走的呀!!话不多说,上bug- .- Uncaught Er ...
- Refused to execute inline event handler because it violates the following Content Security Policy directive: "xxx". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...')
/********************************************************************************* * Refused to exec ...
- Angular5 import interface 报错:XXX is not a module
在项目里定义了一个interface,device.ts.然后在component.ts中要使用这个interface,import之后,VSCode报错:‘xxx/xxx/xxx/device.ts ...
- Vue自定义指令报错:Failed to resolve directive: xxx
Vue自定义指令报错 Failed to resolve directive: modle 这个报错有2个原因: 1.指令单词拼错 2.Vue.directive() 这个方法没有写在 new Vue ...
- Angular2-------Error: Unexpected value ‘undefined’ declared by the module ‘模块名
请检查[app.module.ts]文件中的[declarations]模块最后是否多了一个逗号 (完)
- python学习笔记之module && package
个人总结: import module,module就是文件名,导入那个python文件 import package,package就是一个文件夹,导入的文件夹下有一个__init__.py的文件, ...
- node.js中module.export与export的区别。
对module.exports和exports的一些理解 可能是有史以来最简单通俗易懂的有关Module.exports和exports区别的文章了. exports = module.exports ...
- 通过angularjs的directive以及service来实现的列表页加载排序分页
前两篇:(列表页的动态条件搜索,我是如何做列表页的)分别介绍了我们是如何做后端业务系统数据展示类的列表页以及动态搜索的,那么还剩下最重要的一项:数据展示.数据展示一般包含三部分: 数据列头 数据行 分 ...
- [AngularJS] Directive using another directive by 'require'
Directive can use another directive though 'require' keyword. angular.module('docsTabsExample', []) ...
随机推荐
- 解决ssh远程连接错误问题
使用 Xshell 远程连接服务器时,经常会出现这么个错误提示 WARNING! The remote SSH server rejected X11 forwarding request. ➜ ~ ...
- Spring MVC前后端数据交互总结
控制器 作为控制器,大体的作用是作为V端的数据接收并且交给M层去处理,然后负责管理V的跳转.SpringMVC的作用不外乎就是如此,主要分为:接收表单或者请求的值,定义过滤器,跳转页面:其实就是ser ...
- 彻底弄懂“PKIX path building failed”问题
SSL的基础知识 SSL的全称是Secure Socket Layer.它的通信流程如下图所示,客户端与服务端会通过几次通信,通过非对称加密创建出一个加密密钥,用于以后的对称信息加密. 1,客户端明文 ...
- [LeetCode]640解方程式
问题描述: 示例 1: 输入: "x+5-3+x=6+x-2" 输出: "x=2" 示例 2: 输入: "x=x" 输出: "In ...
- POJ 2643
#include<iostream> #include<stdio.h> #include<string> #include<algorithm> #d ...
- (转)AIX7.1安装Nginx 1.13的方法
原文:https://blog.csdn.net/lvshaorong/article/details/79401860 https://blog.csdn.net/lvshaorong/articl ...
- (转)30 个实例详解 TOP 命令
原文:http://blog.jobbole.com/112873/?utm_source=blog Linux中的top命令显示系统上正在运行的进程.它是系统管理员最重要的工具之一.被广泛用于监视服 ...
- Linux下安装Nginx详细图解教程 (nginx-1.2.6)
什么是Nginx? Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器,在高连接并发的情况下N ...
- Ruby:Net::HTTP
待续... Github上有几个关于Net::HTTP的使用例子:Ruby Net::HTTP cheat sheet Net::HTTP的官方文档 Ruby net/http example这篇文章 ...
- JAVA框架之Hibernate【Hibernate缓存详解】
1.缓存介绍 Hibernate中提供了两级Cache,第一级别的缓存是Session级别的缓存,它是属于事务范围的缓存.这一级别的缓存由hibernate管理的,一般情况下无需进行干预:第二级别的缓 ...