我正在尝试将googlemaps实施到我的angular-cli项目中.我知道有一个'angular2-google-maps'组件(github),但我需要路由和更多自定义功能.
我找到了两种将地图实现到项目中的方法:
1:stackoverflow:使用谷歌api加载器 - 但我无法弄清楚如何初始化谷歌地图...
2:使用DefinitelyTyped google.maps.d.ts.我用--global安装它(因为环境已被弃用..)到我的项目中并将index.d.ts(用于全局)添加到src/typings.d.ts并且可以使用"google.map .." .ts文件:
myLatLng = {lat: -25.363, lng: 131.044};
map:any;
constructor() {
this.map = new google.maps.Map(document.getElementById('map'), {
center: this.myLatLng,
zoom: 4
});
}
Run Code Online (Sandbox Code Playgroud)
但如果我用angular-cli构建它就会出错:"ReferenceError:google is not defined"
有任何想法吗?
我过去为Angular2项目设置了使用npm命令的CI,但是我最近开始使用Angular-CLI,它使用'ng'命令代替.
当我尝试在Visual Studio Online中为我的项目设置CI时,我找不到执行'ng'命令的方法.
我已经尝试运行NPM命令(使用目录中的npm任务)来安装CLI; npm install -g angular-cli,之后运行npm install.现在运行'ng build'我试图使用命令行工具运行(因为似乎没有一个工具允许我运行ng命令),但是没有说ng不是一个公认的命令.
有关使用VSO为Angular-CLI项目设置CI的任何建议?
谢谢
我正在尝试设置代理标头angularcli.这是我目前在proxy.config.json文件中的内容:
"/api": {
"target": "https://applications.str.coni.com/api",
"secure": false,
"logLevel": "debug"
Run Code Online (Sandbox Code Playgroud)
但到目前为止我没有运气,也许我错过了一些东西(可能在另一个文件中).任何建议将不胜感激.
如果导航到路由localhost:4200/login进行更改或刷新它工作正常.
如果我导航到路由localhost:4200/main这是一个子模块(受authguard保护),如果我对这些页面中的任何组件进行更改或刷新,我会收到以下错误.
profile:16 GET http://localhost:4200/main/inline.bundle.js net::ERR_ABORTED
12:53:35.010 profile:16 GET http://localhost:4200/main/polyfills.bundle.js net::ERR_ABORTED
12:53:35.019 profile:16 GET http://localhost:4200/main/styles.bundle.js net::ERR_ABORTED
12:53:35.053 profile:16 GET http://localhost:4200/main/vendor.bundle.js net::ERR_ABORTED
12:53:35.053 profile:16 GET http://localhost:4200/main/main.bundle.js 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
我使用ng serve --watch来提供我的应用程序
@angular/cli: 1.4.5
node: 6.11.3
os: linux x64
@angular/animations: 4.4.4
@angular/cdk: 2.0.0-beta.12
@angular/common: 4.4.4
@angular/compiler: 4.4.4
@angular/core: 4.4.4
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.4.4
@angular/http: 4.4.4
@angular/material: 2.0.0-beta.12
@angular/platform-browser: 4.4.4
@angular/platform-browser-dynamic: 4.4.4
@angular/router: 4.4.4
@angular/cli: 1.4.5
@angular/compiler-cli: 4.4.4
@angular/language-service: 4.4.4
typescript: 2.5.3
Run Code Online (Sandbox Code Playgroud)
还要注意它总是成功编译.
chunk {common} common.chunk.js, common.chunk.js.map (common) 13.8 kB …Run Code Online (Sandbox Code Playgroud) 大量的SO答案说要避免像这样的问题
'Observable'类型中不存在'toPromise'属性
在Angular中,你必须导入我直到最近才做的'rxjs/add/operator/toPromise'.在Angular 4.2.4项目中,我忘记了导入并希望看到错误.它不存在!我在Chrome的开发工具中进行了一些调试,并在Observable的原型上看到了"toPromise".
我的问题是......那是怎么到达那里的?这是TypeScript,Angular还是rxjs的新增功能?
我正在尝试创建一个新的角度项目.我按照本网站提到的步骤进行操作.https://github.com/angular/angular-cli
当我尝试使用ng new命令创建一个新项目时,我收到错误.
E:\Code\> ng new some-name
Error: dryRunSink.commit(...).ignoreElements(...).concat is not a function
dryRunSink.commit(...).ignoreElements(...).concat is not a function
Run Code Online (Sandbox Code Playgroud)
这是结果 ng serve
Angular CLI: 1.6.4
Node: 6.11.4
OS: win32 x64
Run Code Online (Sandbox Code Playgroud)
编辑:看起来每个人都收到此错误.https://github.com/angular/angular-cli/issues/9194
我正在关注着名的Angular教程,英雄之旅,但我正在努力迈出一步.
在第六个课程HTTP上,我们使用了一个模仿API调用API的工具.
我想我已经遵循了所有步骤,到目前为止,它已经说明了以下内容:
刷新浏览器.英雄数据应该从模拟服务器成功加载.
但我可能错过了一些东西:http调用都给出了错误的http 500标题Object(...) is not a function.
我错过了创建路线的一些方法吗?我觉得inMemory wep API似乎不需要路由,这似乎很奇怪.
我的测试代码可以在这里找到:https://github.com/MarcBrillault/tourOfHeroes/tree/StackOverflow
在Angular CLI中,ng serve使用JiT并且--aot需要标志才能使用AoT编译.
是否有可能使ng serve默认使用AoT而JIT仅在--aot=false传递标志时使用?
我是Angular的新手。我看到sourcemap了tsconfig.json,默认情况下是"sourceMap": true。我对此几乎没有疑问,并发现此链接很有用。我仍然对此有以下疑问。
我设置了"sourceMap": false,但在应用程序中找不到任何更改。如果我这样设置的话,实际的变化是什么?
我通常在environment.ts文件中设置API URL 。我必须将同一内部版本部署到具有不同API URL的多个客户端。目前,在更改环境变量之后,我将进行单独的构建。
构建后有什么方法可以编辑环境变量,因此我可以为每个客户端提供相同的构建?
angular-cli ×10
angular ×8
typescript ×2
aot ×1
azure-devops ×1
html ×1
jit ×1
node.js ×1
promise ×1
proxy ×1
rxjs ×1