为什么EventEmitter和Output Decorator需要一起使用?,我看不出两者之间的区别,
如果它们需要一起使用,为什么不只发出一个装饰器并在使用时绑定到选择器!
感谢任何解释!
谢谢
我是 Angular 的新手,并在我的用户界面中使用 ngbootstrap 。默认情况下,我无法在暂停模式下加载 NgbCarousel。下面是我尝试过的代码
import { Component, OnInit, ViewChild } from '@angular/core';
import { NgbCarousel } from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css'],
providers: [NgbCarousel] // add NgbCarouselConfig to the component providers
})
export class DashboardComponent implements OnInit {
constructor(private auth: AuthService, private ngbCarousel: NgbCarousel) {}
ngOnInit() {
this.ngbCarousel.pause();
}
}
Run Code Online (Sandbox Code Playgroud)
下面是html文件:
<div class="jumbotron">
<div class="container">
<div class="row">
<div class="col-12 col-lg-9">
<ngb-carousel>
<ng-template ngbSlide>
<img src="https://lorempixel.com/900/500?r=1" alt="Random first slide">
<div class="carousel-caption">
<h3>First slide label</h3>
<p>Nulla vitae …Run Code Online (Sandbox Code Playgroud) 我想启动新的 Angular 5 项目,但我需要我的代码位于配置文件之外的另一个文件夹中。可以在 cli 命令中做到这一点吗?
例如,这是我的文件夹结构:
-/root
-/src/main/java
-/pom.xml
Run Code Online (Sandbox Code Playgroud)
生成 Angular 5 项目后,我需要它,配置文件将位于src/main/webapp 的根目录和源代码中,如下所示:
-/root
-/src/main/java
-/src/main/webapp
-/src/main/webapp/app
-/src/main/webapp/index.html
-/src/main/webapp/...
-/pom.xml
-/.angular-cli.json
-/package.json
-/...
Run Code Online (Sandbox Code Playgroud)
是否可以?如果是的话怎么办?谢谢。
我必须在从 angular cli 启动 ng serve 命令之前以及在 angular live reload/auto reload 之前运行自定义脚本?除了修改 package.json 之外,是否可以使用 angular 7+?
我最近在尝试使用 angular CLI 创建新组件时开始收到此错误:
newTree.optimize is not a function
Run Code Online (Sandbox Code Playgroud)
发出的命令是:
ng g c test
Run Code Online (Sandbox Code Playgroud)
谷歌搜索只返回来自 Angular CLI v6.x 的文章我试过全局卸载和重新安装 Angular,但没有成功。这是我当前的版本:
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ ? \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | …Run Code Online (Sandbox Code Playgroud) 我正在研究 git bash cmd。当我尝试运行ng命令时,例如ng serve或ng gc new-component我看到这个输出:
C:\Users\user\AppData\Roaming\npm/node_modules/node/bin/node: line 1: this: command not found
在输出中间,我看到左右斜线有问题。我该如何解决?
我想,环境路径没有问题,因为所有 ng 命令都在 Windows cmd 或 PowerShell 中工作。
我从 Angular 9.17 升级到 9.19,现在 ng build 失败并出现以下错误,抱怨@types/node 和 zone.js 中的变量声明:
node_modules/@types/node/ts3.5/globals.global.d.ts:1:13 中的错误 - 错误 TS2403:后续变量声明必须具有相同的类型。变量“global”必须是“Global”类型,但这里的类型是“Global & typeof globalThis”。
1 声明var global: NodeJS.Global & typeof globalThis; ~~~~~~
node_modules/zone.js/dist/zone.js.d.ts:600:13 600 声明 var global: NodeJS.Global; ~~~~~~ 'global' 也在这里声明。
升级前运行良好,现在无法构建。这是唯一的变化。
请帮忙。
我的 package.json
{
"name": "myapp",
"private": true,
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "echo hello && ng serve --live-reload=false",
"build": "node --max_old_space_size=4096 ng build",
"build:ssr": "ng run MIC:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"postcss": {},
"dependencies": …Run Code Online (Sandbox Code Playgroud)ERROR in pathType.isDirectory is not a function每当我ng serve在终端中运行时,我都会收到错误消息。检查控制台时,错误说:
Refused to load the image 'http://localhost:4200/favicon.ico' because it violates the following Content Security Policy directive: "default-src 'none'". Note that 'img-src' was not explicitly set, so 'default-src' is used as a fallback. 以及经典的 404。
我尝试删除 favicon.ico 以及更新到最新版本的 node、npm 和 angular 都无济于事。关于如何调试它的任何建议/帮助?
运行时出现以下错误npm build --prod:
Error: budgets: initial exceeded maximum budget. Budget 1.00 MB was not met by 500.42 kB with a total of 1.49 MB.
我也收到此警告:
Warning: C:\Users\PATH_TO_FILE\socket.service.ts depends on 'socket.io-client'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
我还导入了很多 Angular Material 模块。这是我的app.module.ts(这是我整个项目中唯一的模块):
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FontAwesomeModule } from …Run Code Online (Sandbox Code Playgroud) 我正在尝试让我的应用程序部署在 Heroku 上。我收到了“sh: 1: ng: not found”错误,但根据这里的回复,我移动了我的@angular/cli、@angular-devkit/build-angular、@angular/compiler-cli 和 typescript。现在我收到“无法解析依赖项:npm ERR!peer @angular/compiler@"11.2.8"”错误。我认为它有一个版本问题?我不确定发生了什么。
我试过运行 'npm update' 并尝试手动将 '@angular/compiler@"11.2.8"' 插入依赖项,然后运行 'npm i' 但两者都给我同样的错误。
这是我的错误:
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR! @angular/compiler@"~11.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.2.8" from @angular/compiler-cli@11.2.8
npm ERR! node_modules/@angular/compiler-cli
npm ERR! dev @angular/compiler-cli@"^11.0.9" from the root project
npm ERR! peer @angular/compiler-cli@"^11.0.0" from @angular-devkit/build-angular@0.1100.7
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! @angular-devkit/build-angular@"~0.1100.2" from the root project
Run Code Online (Sandbox Code Playgroud)
包.json:
"scripts": {
"ng": …Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×7
typescript ×2
angular9 ×1
bash ×1
git-bash ×1
ng-bootstrap ×1
optimization ×1
socket.io ×1
zonejs ×1