在我的Angular 2.0.0-rc.7+ Angular Material 2.0.0-alpha.8-1应用程序构建中Angular CLI 1.0.0-beta.11-webpack.9-1,从rc.5+ alpha.7-4(从1.0.0-beta.11-webpack.8NG CLI)升级后出现以下错误:
main.bundle.js:44545 Error: No provider for Overlay!
at NoProviderError.Error (native)
at NoProviderError.BaseError [as constructor] (http://localhost:4200/main.bundle.js:7032:34)
at NoProviderError.AbstractProviderError [as constructor] (http://localhost:4200/main.bundle.js:44258:16)
at new NoProviderError (http://localhost:4200/main.bundle.js:44289:16)
at ReflectiveInjector_._throwOrNull (http://localhost:4200/main.bundle.js:65311:19)
at ReflectiveInjector_._getByKeyDefault (http://localhost:4200/main.bundle.js:65339:25)
at ReflectiveInjector_._getByKey (http://localhost:4200/main.bundle.js:65302:25)
at ReflectiveInjector_.get (http://localhost:4200/main.bundle.js:65111:21)
at NgModuleInjector.get (http://localhost:4200/main.bundle.js:45173:52)
at ElementInjector.get (http://localhost:4200/main.bundle.js:65475:48)ErrorHandler.handleError @ main.bundle.js:44545
main.bundle.js:44548ERROR CONTEXT:ErrorHandler.handleError @ main.bundle.js:44548
Run Code Online (Sandbox Code Playgroud)
我的package.json依赖是:
"dependencies": {
"@angular/common": "2.0.0-rc.7",
"@angular/compiler": "2.0.0-rc.7",
"@angular/core": "2.0.0-rc.7",
"@angular/forms": "2.0.0-rc.7",
"@angular/http": …Run Code Online (Sandbox Code Playgroud) 我正在为Angular 2项目使用Angular-CLI(webpack版本),我也需要使用jQuery(遗憾的是.在我的情况下,它是Semantic-UI的依赖,我用它来处理菜单下拉菜单).
我使用它的方式:
npm install jquery --save
Run Code Online (Sandbox Code Playgroud)
然后列在数组中的angular-cli.json文件中scripts:
scripts": [
"../node_modules/jquery/dist/jquery.min.js"
]
Run Code Online (Sandbox Code Playgroud)
所以它被包含在bundle文件中,这个文件自动用于root html文件:
<script type="text/javascript" src="scripts.bundle.js">
然后declare var $: any;在我需要它的文件中,它运行良好.
但是ng test测试存在问题,因为Karma会抛出错误$ is not defined.
所以我想在我的Angular 2应用程序中包含一个外部JS库,一个旋转木马滑块.我已经看过很多教程,展示了如何添加它我已经成功完成了,但引用了index.html上的库.
如您所知,每次访问应用程序时都会加载库,无论他们是否访问需要轮播的组件.由于它非常大,我只想在需要的地方加载它,这是在一个延迟加载的模块中.
我没有尝试过,但我确信我可以在使用它的组件中查看脚本标记,但这对我来说感觉不对.
必须有正确的方法.它是什么!?
谢谢!
我在几个项目中使用angular2.每个项目都使用不同版本的angular-cli,因此,我需要能够使用正确版本的angular-cli分别运行和编译生产.当我使用save-dev安装angular-cli local时,找不到ng命令,所以我无法为项目创建构建分发.所以问题是,如何在同一台机器上安装多个angular-cli版本,而无需全局安装(使用-g选项)?,可以运行命令而无需全局安装angular-cli?请向任何指向正确方向的人表示非常感谢.
提前致谢...
我正在尝试切换href一个<link />用于主题目的,并且SCSS主题存在于我的monorepo的包文件夹中,这些文件夹是符号链接的node_modules.我需要能够编译和引用这些.
我遇到了以下固定问题:angular/angular-cli#3401并且一直试图实现类似的东西:
"styles": [
"styles.scss",
{
"input": "../node_modules/@org/themes/dark.scss",
"output": "dark",
"lazy": true
}
],
Run Code Online (Sandbox Code Playgroud)
我的理解(也许是不正确的)是这会将dark.scss文件编译成dist/dark.bundle.css我可以通过http:// localhost:4200/dist/dark.bundle.css加载它但是它没有按预期工作.我误解了某些事情或完全错误吗?
如何编译SCSS文件node_modules,然后我可以在应用程序中延迟加载?我可以尝试另一种/更好的方法吗?
补充说明:
4.2.41.3.0node_modules/@org/themes是一个符号链接ng serve --preserve-symlinks选项,以防上述问题.它没有任何区别我已经研究过Angular Material docs网站解决这个问题的方式,看起来他们有一个自定义构建脚本,assets在服务应用程序之前将SCSS文件编译成目录中的CSS文件.我认为上面修复的问题消除了对这一步的需要,但也许没有.这是唯一可行的方法吗?
感谢@Kuncevic.我错过了--extract-css国旗.
工作配置:
"styles": [
"styles.scss",
{
"input": "../node_modules/@org/themes/src/dark.scss",
"output": "themes/dark",
"lazy": true
}
],
Run Code Online (Sandbox Code Playgroud)
使用以下服务脚本,我可以通过http:// localhost:4200/themes/dark.bundle.css访问它:
ng …
Angularjs和angular之间的区别是什么(例如cli和版本)?
我想工作Angular,但我不知道选择其中一个的差异.我用谷歌搜索,但没有明确提到它们之间的差异.
我是角色的新手,并希望在组件ngOnInit方法中格式化日期.我已经看到一些示例,其中管道运算符用于格式化数据,但我不知道如何格式化组件文件中的日期.
下面是代码
export class DashboardComponent implements OnInit {
formatdate = 'dd/MM/yyyy';
constructor(private auth: AuthService) { }
ngOnInit() {
console.log(new Date().toISOString())
}
}
Run Code Online (Sandbox Code Playgroud) 这是我的Angular5项目结构.
双方tsconfig.app.json并package.json包含这部分
"include": [
"/src/main.ts",
"/src/polyfills.ts"
]
Run Code Online (Sandbox Code Playgroud)
但无论我尝试什么,我仍然会收到此错误:
\polyfills.ts & \main.ts is missing from the TypeScript compilation.
Please make sure it is in your tsconfig via the 'files' or 'include' property.
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
src/tsconfig.app.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"module": "es2015",
"types": …Run Code Online (Sandbox Code Playgroud) 所以这个问题很基本,但我找不到.
我创建了一个新的应用程序ng new my-project,然后是一个ng g library my-library.然后我执行了命令ng build,但是只是构建我的应用程序,而不是我的库或我的e2e项目.这是因为在angular.json中,defaultProject设置为my-project.我可以将它更改为my-library,然后ng build将构建lib.
有没有办法让角度在一个ng-build中构建所有项目和库?
我正在使用Bootstrap 4开发Angular应用程序。
我需要与我的angular应用程序中添加的scss相关的帮助。
我的问题是:
即
npm install bootstrap --save
Run Code Online (Sandbox Code Playgroud)
然后,打开angular.json文件,并将引导文件路径添加到样式部分。喜欢:
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
Run Code Online (Sandbox Code Playgroud)
以上两种方式的角度是否相同。
angular ×10
angular-cli ×10
angular6 ×1
angular7 ×1
angularjs ×1
bootstrap-4 ×1
external-js ×1
jquery ×1
npm ×1
package.json ×1
sass ×1
typescript ×1
webpack ×1