标签: angular-cli

使用 rxjs 时如何获取错误的堆栈跟踪?

我正在使用 angular-cli 构建一个小型 angular2 Web 应用程序,并且正在使用 chrome dev-tools 进行调试。

显然,如果我每次都需要猜测错误的来源以及该错误的堆栈跟踪是什么,那么我做错了什么。

以这个错误为例:

error_handler.js:45EXCEPTION: Cannot read property 'provider' of nullErrorHandler.handleError @ error_handler.js:45
error_handler.js:50ORIGINAL STACKTRACE:ErrorHandler.handleError @ error_handler.js:50
error_handler.js:51TypeError: Cannot read property 'provider' of null
    at MapSubscriber.project (auth.effects.ts:80)
    at MapSubscriber._next (map.js:77)
    at MapSubscriber.Subscriber.next (Subscriber.js:89)
    at DistinctUntilChangedSubscriber._next (distinctUntilChanged.js:72)
    at DistinctUntilChangedSubscriber.Subscriber.next (Subscriber.js:89)
    at MapSubscriber._next (map.js:83)
    at MapSubscriber.Subscriber.next (Subscriber.js:89)
    at MapSubscriber._next (map.js:83)
    at MapSubscriber.Subscriber.next (Subscriber.js:89)
    at RefCountSubscriber.Subscriber._next (Subscriber.js:125)ErrorHandler.handleError @ error_handler.js:51
zone.js:355Unhandled Promise rejection: Cannot read property 'provider' of null ; Zone: <root> ; Task: Promise.then ; Value: …
Run Code Online (Sandbox Code Playgroud)

javascript google-chrome-devtools rxjs angular-cli angular

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

不能使用 ReactiveFormsModule

我正在尝试ReactiveFormsModule在项目中使用。所以我将它添加到app.module.ts:

import { NgModule }                                     from '@angular/core';
import { FormsModule, ReactiveFormsModule }             from '@angular/forms';
import { BrowserModule }                                from '@angular/platform-browser';
import { LocationStrategy,
         HashLocationStrategy }                         from '@angular/common';

import { AppComponent }                                 from './app.component';
import { Ng2BootstrapModule }                           from 'ng2-bootstrap/ng2-bootstrap';
import { NAV_DROPDOWN_DIRECTIVES }                      from './shared/nav-dropdown.directive';

import { ChartsModule }                                 from 'ng2-charts/ng2-charts';
import { SIDEBAR_TOGGLE_DIRECTIVES }                    from './shared/sidebar.directive';
import { AsideToggleDirective }                         from './shared/aside.directive';
import { BreadcrumbsComponent }                         from './shared/breadcrumb.component';

// Routing Module
import { AppRoutingModule } …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-forms angular-cli angular

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

Angular-CLI 慢 - 块资产优化和资产优化花费大量时间

在使用 angular-cli 开发 angular 2 时,块资产优化和资产优化ng serve在我的旧 macbook 上花费了大量时间,例如:

9952ms chunk asset optimization
2432ms asset optimization
Run Code Online (Sandbox Code Playgroud)

每次更改都等待这个时间变得非常烦人。是否有可能删除/减少这个时间,他在开发过程中不会在每次更改时发生?

angular-cli angular

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

在 IIS 上提供 bundle.js.gz 文件

我正在使用 Angular 2 最新的 CLI 来捆绑和构建应用程序。

因此,CLI 生成了我想在 IIS 服务器上托管的“main.bundle.js.gz”文件。

我不确定如何配置 IIS 以提供压缩内容。

当我手动更改“index.html”文件以指向“.gz”文件时,它不起作用。有没有人在 IIS 上尝试过,并且可以提供一些如何配置它以使其工作的线索。

我知道 IIS 内置了压缩支持,但我不想使用它。我想通过 Angular CLI 提供已经压缩的文件。

任何帮助都将得到认可。

iis angular-cli angular

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

Angular Cli - 如何重建我的项目

如何在 Angular 中重建我的项目。我首先使用 ng build 构建它,但无法再次执行该命令,因为它不会让我更改文件夹。

我收到此错误消息:EPERM:不允许操作,lstat

是否有另一个命令,例如 ng build update ?

angular-cli

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

如何加快 Angular CLI Live Reload - 每次更改 1-2 分钟

我一直在为我的 ng2 项目使用 AngularCLI,并且在过去几个月中它一直很棒。最近几周,它似乎变得越来越慢。

如果我进行简单的 HTML 更改,现在需要 1 到 2 分钟才能使用“ng serve”运行并刷新浏览器。发生这种情况时,NodeJS 会消耗大量 RAM 和 CPU。

我在我旁边的一台新笔记本电脑上运行了相同的代码和进程,大约需要 20 秒。我目前在 Windows Home 10 上使用 CLI 1.0.0-beta.21。我有 8 个演出内存/SSD/i7。

我试过了:

  • 删除和重新安装节点模块
  • 升级到最新的 CLI 版本
  • 关闭 Windows Defender(并从扫描中排除 Node/和 proj 文件夹)

一切都无济于事。

这是输出:

webpack: bundle is now INVALID.
6938ms building modules
72ms sealing
4ms optimizing
1ms basic module optimization
1074ms module optimization
5ms advanced module optimization
149ms basic chunk optimization
1ms chunk optimization
1ms advanced chunk optimization
702ms module and chunk tree optimization …
Run Code Online (Sandbox Code Playgroud)

livereload angular-cli

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

运行 Angular 编译器-cli (ngc);找不到模块“@angular/core”

我尝试使用以下方法安装 Angular compiler-cli (ngc):

npm install @angular/compiler-cli typescript @angular/platform-server @angular/compiler
Run Code Online (Sandbox Code Playgroud)

并且安装似乎有效,但是现在当我运行时ngc -p src,根据这个问题的解决方案,我得到:

module.js:442
    throw err;
    ^

Error: Cannot find module '@angular/core'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at /usr/local/lib/node_modules/@angular/compiler/bundles/compiler.umd.js:7:83
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/compiler/bundles/compiler.umd.js:10:2)
    at Module._compile (module.js:541:32)
    at Object.Module._extensions..js (module.js:550:10)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
Run Code Online (Sandbox Code Playgroud)

我的项目运行良好ng serve。我在这里做错了什么?

typescript angular-cli angular

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

使用 Angular CLI 的 Google Chrome 扩展卡在“加载”状态

我尝试使用 angular CLI 开发一个简单的 Google Chrome 扩展程序,但它卡在Loading.

在此处输入图片说明

如果我尝试正常使用我的应用程序npm start并在浏览器的窗口中打开它,它工作正常。

在此处输入图片说明

我也尝试使用编译我的应用程序ng build,将我的manifest.json放在我的dist文件夹中,但结果是一样的。

我的 manifest.json :

{
  "manifest_version": 2,

  "name": "Weather for Chrome",
  "description": "Weather for Chrome is a simple Google chrome plugin using angular CLI",
  "version": "1.0",

  "browser_action": {
    "default_icon": "assets/Soleil.png",
    "default_popup": "index.html"
  },
  "permissions": [
    "activeTab",
    "https://ajax.googleapis.com/"
  ]
}
Run Code Online (Sandbox Code Playgroud)

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { …
Run Code Online (Sandbox Code Playgroud)

plugins google-chrome-extension typescript angular-cli angular

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

在打字稿中扩展数组原语(angular-cli 项目)

我需要能够轻松对集合进行排序,并且我选择扩展 Array 原语。我意识到在大多数情况下这被认为是不好的做法,但这只会在内部使用(不是共享库)。无论我尝试过什么方法,我都没有得到有效的结果。我不断收到错误:TypeError: Attempted to assign to readonly property。这是我最近一次迭代的简化示例。我在操场上有一个更完整的版本,所以我假设他的问题在于 angular-cli 配置/构建过程???

interface Array<T> {
  $sortBy(sortKey:string): T[];
}

if (!Array.prototype['$sortBy']) {

  Object.defineProperty(Array.prototype, '$sortBy', {
    value: function(sortKey) {
      return this.sort( function(a, b) { // TypeError here???
        if (a[sortKey] < b[sortKey]) { return -1; }
        if (a[sortKey] > b[sortKey]) { return 1; }
        return 0;
      });
    }
  }

}
Run Code Online (Sandbox Code Playgroud)

我也试过这种方法,但我的 IDE (VSCode) 给了我错误: [ts] Property '$sortBy' does not exist on type 'any[]'.

         Intellisense error here
                   |
                   V
Array.prototype.$sortBy = …
Run Code Online (Sandbox Code Playgroud)

javascript extend typescript angular-cli angular

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

如何在 angular 2 中使用 Google Sheet API V4?

我正在尝试创建一个要在 Excel 工作表中更新的应用程序。我遇到了https://github.com/dwyl/html-form-send-email-via-google-script-without-server,它显然不适用于 angular。将 ajax 调用替换为

onsubmitForm() {
  let headers = new Headers();
  headers.append('Access-Control-Allow-Origin','*');
  let options = new RequestOptions({ headers: headers });
  let body = {
    name:"lala",
    message:"ssss",
    email:"a@k.com",
    color:"red"
  }
return this.http.put('https://script.google.com/macros/s/AKfycbxJKxvzl8Go5ZihUc95su-HFvFeoTtnMyA3qq5YiBxcDYalDdOb/exec', body).toPromise(); }
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息,“对预检请求的响应未通过访问控制检查:没有‘Access-Control-Allow-Origin’”。有办法解决吗?或者可能是使用 angular 2 将数据添加到 Excel 工作表的另一种方法?

angular-cli google-sheets-api angular

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