标签: angular-cli

如何使用angular-cli自定义bootstrap 4

我有一个使用angular-cli 1.0和Bootstrap 4-alpha6的Angular 4应用程序.我想自定义Bootstrap 4.例如,更改主按钮的颜色.

它必须是一个面向未来的解决方案.这意味着我的自定义必须在以后的某个时间点升级引导程序.

我已经集成了bootstrap:添加 "bootstrap": "4.0.0-alpha.6",到package.json文件中的依赖项.此外,我补充道

"styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"
      ],
Run Code Online (Sandbox Code Playgroud)

到"apps"在角cli.json.

我的第一个尝试是创建一个名为style.scss的新文件,将其放入src/assets中,并在angular-cli.json中引用它.

内容可能如下所示:

@import "../../node_modules/bootstrap/scss/variables";
@import "../../node_modules/bootstrap/scss/mixins";

$body-bg:    $gray-dark;
$body-color: $gray-light;
Run Code Online (Sandbox Code Playgroud)

运行ng serve应用程序时,comiles正常,但我没有看到任何更改.

我是否开始朝着正确的方向前进?如何在干净的angular-cli工作流程中通过sass正确地自定义引导按钮/样式?

你可以在这里找到源:https://github.com/nemoo/democratizer-angular/tree/ngbootstrap/frontend-angular

twitter twitter-bootstrap twitter-bootstrap-4 angular-cli angular

5
推荐指数
1
解决办法
4007
查看次数

角度2"失败:运行ng测试时无法读取未定义的属性'替换'

我已经检查了这个问题的github问题,并查看了各种堆栈溢出问题和博客和内容,我找不到解决方案,为什么我在我的角度2应用程序中运行"ng test"时出现此错误.

这是测试的样子:

import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { RouterModule } from "@angular/router";
import { Location,LocationStrategy } from "@angular/common";

describe('App: MemberAdmin', () => {
  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
      imports:[
        RouterModule
      ],
      providers:[
        Location,
        LocationStrategy
      ]
    });
  });

  it('should create the app', async(() => {
    let fixture = TestBed.createComponent(AppComponent);
    let app = fixture.debugElement.componentInstance;
    expect(app).toBeTruthy();
  }));

  it(`should have as title 'app works!'`, async(() => {
    let fixture = TestBed.createComponent(AppComponent); …
Run Code Online (Sandbox Code Playgroud)

unit-testing angular-cli angular

5
推荐指数
1
解决办法
1997
查看次数

ENOENT:没有这样的文件或目录,stat'/ sources /src/tsconfig.json' - angular-cli

我使用deploybot工具将我的角度站点从bitbucket部署到AWS S3,它以前工作得很好,但现在我已从angular 2升级到angular 4.1.2和angular-cli @ latest => 1.0.0

在deploybot中安装npm之后我的文件结构是

-rw-r--r-- 1 1001 999 1295 May 10 09:59 README.md
-rw-r--r-- 1 1001 1002 2770 May 27 09:35 tslint.json
-rw-r--r-- 1 1001 1002 385 May 27 09:35 tsconfig.json
drwxr-xr-x 5 1001 999 4096 May 27 09:35 src
-rw-r--r-- 1 1001 1002 756 May 27 09:35 protractor.conf.js
-rw-r--r-- 1 1001 1002 1785 May 27 09:35 package.json
-rw-r--r-- 1 1001 1002 1240 May 27 09:35 karma.conf.js
drwxr-xr-x 2 1001 999 4096 May 27 09:35 …
Run Code Online (Sandbox Code Playgroud)

deployment angular-cli angular

5
推荐指数
0
解决办法
3415
查看次数

如何使用angular-cli创建要素模块

我正在使用angular-cli来创建一个功能模块.之前这个模块在我的主角应用程序(也是使用angular-cli创建)中只是另一个模块.现在我想将它移动到一个单独的模块,它可以单独发布,其他人可以将它用作第三方库.

我能够发布它,但当我尝试使用它的主角度应用程序时,导入失败.我可以看到我的功能模块存在于node_modules文件夹中,但目录结构与我正在使用的所有第三方角度库(bootstrap,angular-split等)非常不同.

看起来我的功能模块的目录结构不正确.如何使用angular-cli创建功能模块以及目录结构应该如何?

在此输入图像描述

angular-cli

5
推荐指数
0
解决办法
306
查看次数

'ng'不被识别为内部或外部命令,

我刚刚开始使用CLI,当我尝试安装@ angular/cli并运行代码时 ng --help

我收到以下错误

'ng'不被识别为内部或外部命令,

我已经浏览了所有博客,并且在按照博客中列出的所有步骤后没有找到任何帮助

  1. 我改变了

用户变量路径:; C:\ Program Files \nodejs \和系统变量:C:\ Program Files \nodejs \;%AppData%\npm ;;

  1. 当我运行命令

    npm install -g @ angular/cli

我在node_modules文件夹下找到了以下文件

@angular

-cli

---斌

----- NG

CLI

我试图使用清理缓存

npm cache clean 
Run Code Online (Sandbox Code Playgroud)

然后运行代码

ng --version
Run Code Online (Sandbox Code Playgroud)

但我收到标题中提到的错误

angular-cli angular

5
推荐指数
3
解决办法
2万
查看次数

每次在.ts文件中添加断点时,Chrome都会在main.bundle.ts中打开相应的行

我正在开发一个Angular(v4.3.5)SPA,使用Angular CLI的ng serve命令为其提供服务,并通过Chrome Developer Tools进行调试.上周发生了一些奇怪的事情,我似乎无法做任何事情来改变它以前的方式:在Chrome开发工具中,当我点击行号在我的.ts文件中添加一个断点时,Chrome开发工具也打开相应的行main.bundle.ts,所以现在我每次添加一个断点我都要关闭main.bundle.ts或点击.ts文件标题.这很烦人.默认设置有什么新变化吗?因为我找不到任何相关的东西(虽然我甚至不确定如何谷歌这个问题...)

所以我的问题是:main.bundle.ts每次添加断点时,我该怎么办才能强制Chrome不打开?

编辑:我刚刚发现这个问题只有在我ng serve从Visual Studio Code终端运行时才会发生.

google-chrome-devtools webpack visual-studio-code angular-cli angular

5
推荐指数
1
解决办法
357
查看次数

错误:无法解析'child_process'Angular-cli

我使用angular-cli生成了一个新的应用程序并添加了一些组件.我没有添加任何测试用例.当我尝试运行/构建应用程序时,我收到以下冗长的错误消息:

ERROR in ./node_modules/selenium-webdriver/firefox/binary.js
Module not found: Error: Can't resolve 'child_process' in '/home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox'
resolve 'child_process' in '/home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox'
  Parsed request is a module
  using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./firefox)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/package.json (relative path: ./firefox)
    resolve as module
      /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/selenium-webdriver/firefox/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/fruit-stall/fruitStall/node_modules/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/fruit-stall/node_modules doesn't exist or is not a directory
      /home/myName/PROJECTS/MEAN/node_modules doesn't exist or is not a directory …
Run Code Online (Sandbox Code Playgroud)

node.js angularjs selenium-webdriver angular-cli

5
推荐指数
1
解决办法
5128
查看次数

按钮标记内的路由器链接属性不起作用

我无法使用放在button标记内的路由器链接属性进行导航。这是我的代码,

<button mat-raised-button color="primary"><a routerLink="/message-inbox">Inbox</a></button>
    <button mat-raised-button color="accent"><a routerLink="/sent">Sent</a></button>
    <a routerLink="/message-compose"><button color="warn">Compose</button></a>
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

5
推荐指数
2
解决办法
1万
查看次数

如何从Mat对话框组件与实现Mat对话框的组件进行通信?

我有一个对话框组件和应用程序组件,用于实现材质对话框。 这是应用程序组件的代码

import { Component } from '@angular/core';
import {VERSION, MatDialog, MatDialogRef} from '@angular/material';
import { DialogComponent } from '../dialog.component';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular 5';
  DialogRef: MatDialogRef<DialogComponent>;
  constructor(private dialog: MatDialog) {}
  ngOnInit() {
  }
  addItem() {
    this.DialogRef = this.dialog.open(DialogComponent);
  }

receiveMessageFromDialogComponent() {
  // how to receive message from dialog component
}
closeDialog(): void {
  this.DialogRef.close();
}
}
Run Code Online (Sandbox Code Playgroud)

对话框组件是实现表单的地方,我需要获取表单值并在此处接收它。我尝试使用角度输入和输出来实现此目的,但是精巧的工作因为没有孩子和父母的交流。这是对话框组件

import { Component } from '@angular/core';

@Component({
  template: …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

5
推荐指数
2
解决办法
7030
查看次数

您的全局Angular CLI版本大于本地版本

我已经在新机器上安装了最新的angular-cli,我正在尝试使用之前的cli版本生成一个项目

我得到了这个警告

Your global Angular CLI version (1.6.4) is greater than your local
version (1.6.3). The local Angular CLI version is used.

To disable this warning use "ng set --global warnings.versionMismatch=false".
Run Code Online (Sandbox Code Playgroud)

虽然该项目正常工作,我有什么办法,以更新我的项目与最新的dependecies,并避免这个消息(避免不抑制!)

这是我的package.json

{
    "name": "AngularTest",
    "version": "0.0.0",
    "license": "MIT",
    "angular-cli": {},
    "scripts": {
        "ng": "ng",
        "start": "ng serve --host 0.0.0.0 --port 4200",
        "hmr": "ng serve --host 0.0.0.0 --port 4200 4201 --hmr -e=hmr",
        "test": "ng test",
        "pree2e": "webdriver-manager update --standalone false --gecko false",
        "e2e": "protractor"
    },
    "private": true,
    "dependencies": { …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

5
推荐指数
1
解决办法
8717
查看次数