当我在webpack项目中导入像momentjs这样的库时,webpack也会自动包含所有可选的依赖项.对于我这样做的时刻:
import * as moment from 'momentjs'
Run Code Online (Sandbox Code Playgroud)
我将200kb添加到我的捆绑包中,因为这会自动包含所有可能的区域设置.区域设置为150kb,库本身仅为50kb.在这个问题中,它描述了如何在ContextReplacementPlugin的帮助下在webpack配置中排除这些依赖关系.
如何在我无法直接访问webpack配置的angular-cli项目中执行此操作(除非我弹出具有其他副作用的配置).
我正在尝试使用传单和其他传单插件来实现地图组件。问题是由于某种原因,其他插件无法从TypeScript使用。
例如,我无法使用Leaflet-Draw插件编译代码并得到以下错误:
属性“ Draw”在类型“ typeof Control”上不存在
mapbox.component.ts
import { DataService } from "../data-service.service";
import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
/// <reference types="leaflet" />
/// <reference types="leaflet-draw" />
declare var require: any
@Component({
selector: 'app-mapbox',
templateUrl: './mapbox.component.html',
styleUrls: ['./mapbox.component.css']
})
export class MapboxComponent implements OnInit {
constructor(private dataService: DataService) { }
// helper flags
map: L.Map = null;
aggreagte: boolean = false;
ngOnInit() {
// Prepare map
this.map = L.map('resultmap').setView([51.505, -0.09], 1);
//
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', …Run Code Online (Sandbox Code Playgroud) 我的Ng2项目有问题需要3到4天.
我运行serv/ng测试或ng build,我有:"超出最大调用堆栈大小的错误"
"服务"之后
$ ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: a73c4ecdb8222366629e
Time: 16536ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 405 kB {5} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 41.1 kB {4} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 149 kB {5} [initial] [rendered]
chunk …Run Code Online (Sandbox Code Playgroud) 我是Angular 4和Angular-CLI的新手.我找不到任何解决方案如何为整个应用程序使用root scss/css文件.因此,我的问题是,如何在项目中使用全局scss文件?
它完全适用于Http,但不适用于WebSocket.我没有找到关于此的文档.我怎样才能代理WS?
ng serve --proxy-config proxy.conf.json
Run Code Online (Sandbox Code Playgroud)
proxy.conf.json:
{
"/": {
"target": "http://localhost:8080",
"secure": false
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个遗留的JS文件,用以下RequireJS(AMD)模块表示法编写:
define('mymodule', [], function(){
// ... bla bla bla
return {
calculate: function() { return 1 + 1; }
};
});
Run Code Online (Sandbox Code Playgroud)
我正在从使用RequireJS的另一个(遗留)项目导入此文件,因此 - 我无法更改使用的模块定义.
我想在用TypeScript编写的Angular Cli(Angular 4.x)应用程序中导入它.
由于Angular Cli使用Webpack 2来构建支持AMD的项目,我想我可以像这样导入它:
import * as MyModule from './mymodule.js';
Run Code Online (Sandbox Code Playgroud)
...但是这不起作用,它会触发一个mymodule.js不是模块的错误.
任何想法(或解决方法)如何导入此旧模块?
如何将“ [对象对象]”(日期选择器)转换为日期格式
<input type="text"
id="date"
class="form-control"
formControlName="date"
name="date"
[(ngModel)]="date"
ngbDatepicker
#incorporatedDatePicker="ngbDatepicker"
(click)="incorporatedDatePicker.toggle()"
readonly>
Run Code Online (Sandbox Code Playgroud)
当我展示
{{meeting.date | date }}
Run Code Online (Sandbox Code Playgroud)
我有错误:管道'DatePipe'的invalidPipeArgument错误'[object Object]'
我开发了Tour of Heroes Angular教程应用程序.之后我写了组件的测试.应用程序和组件测试都很好.现在我想用Protractor开发E2E测试,我无法让它们运行.
每次我ng e2e在命令行上运行时,我都会得到以下输出:
$ ng e2e
** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2017-09-26T14:51:12.962Z
Hash: ef70100f8d31703b6b85
Time: 8035ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 5.83 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 3.16 MB {inline} [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 209 kB {inline} [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 11.6 kB {inline} [initial] [rendered]
(node:13556) [DEP0022] DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() …Run Code Online (Sandbox Code Playgroud) 我们希望在ASP.NET核心中为我们的项目使用Angular CLI.作为输出,我们选择wwwroot而不是dist.默认ng服务可自动更换热模块.但是现在我们需要使用kestrel和iis集成来替换热模块.我们决定不使用AspNet核心Javascriptservices,因为我们希望使用Angular CLI作为默认值.
有谁知道如何使用Angular CLI替换热模块替换和使用wwwroot中的静态文件的ASP.NET核心标准hostring?
在我的angular 5应用中,[ngStyle]没有扩展到样式属性。我只看到ng-reflect-ng-style。这曾经工作过。Angular或Angular-cli的最新更新是否有所变化?
这是模板:
<div *ngIf="ready" class="card" [ngStyle]="dimensions">
</div
Run Code Online (Sandbox Code Playgroud)
这是生成的HTML:
<div _ngcontent-c6="" class="card ng-tns-c6-1" ng-reflect-ng-style="[object Object]">
</div>
Run Code Online (Sandbox Code Playgroud)
预期,尺寸= {width:'240px'}:
<div _ngcontent-c6="" class="card ng-tns-c6-1" ng-reflect-ng-style="[object Object]" style="width:240px">
</div>
Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×9
typescript ×3
webpack ×2
asp.net-core ×1
date ×1
datepicker ×1
leaflet ×1
leaflet.draw ×1
momentjs ×1
protractor ×1
requirejs ×1
sass ×1