我需要弄清楚如何使用我的本地Web服务器进行实时重新加载.我正在使用vagrant在http://admin.myproject.local上托管我的项目,并使用angular-cli构建我的应用程序.
使用时,npm start我可以在http:// localhost:4200上查看我的更改,但在我的admin.myproject.local上没有任何更改,直到进行构建.我查看了angular-cli文档,并认为代理将是解决方案.我创建了一个proxy.conf.json文件并添加了以下代码:
{
"/admin": {
"target": "http://admin.myproject.local",
"secure": "false"
}
}
Run Code Online (Sandbox Code Playgroud)
然而,这似乎没有帮助.如果我尝试http:// localhost:4200/admin我得到404.
当有人通过我的.local网址访问网站时,有人能指出我正确的方向来实现重新加载吗?
我在整合Electron时遇到了一些麻烦.当我按照博客文章中的描述使用它时,一切正常.当我想使用import Electron(electron.remote)在Angular2服务中使用它来让应用程序使用桌面功能(如系统对话框和文件系统访问)时出现问题.
加载应用程序时,我收到以下错误,包含在webpack包中的electron/index.js中:
Uncaught TypeError: fs.existsSync is not a function (index.js:6)
Run Code Online (Sandbox Code Playgroud)
该文件看起来很简单:
var fs = require('fs')
var path = require('path')
var pathFile = path.join(__dirname, 'path.txt')
if (fs.existsSync(pathFile)) {
module.exports = path.join(__dirname, fs.readFileSync(pathFile, 'utf-8'))
} else {
throw new Error('Electron failed to install correctly, please delete node_modules/' + path.basename(__dirname) + ' and try installing again')
}
//////////////////
// WEBPACK FOOTER
// ./~/electron/index.js
// module id = 609
// module chunks = 2
Run Code Online (Sandbox Code Playgroud)
这里有趣的是,另一个内置模块路径在同一段代码中没有问题.当我查看电子应用程序的开发工具时,我可以看到预期的path方法以及两个静态属性(分隔符).但是,当我看到 …
我已经基于agnular-cli版本1.0.0-beta.24构建应用程序.我想根据https://universal.angular.io/上的教程添加通用,但它根本不起作用.我也尝试过来自https://www.npmjs.com/package/universal-cli的 universal-cli ,但在合并项目之后,出现了太多错误.命令ung init --universal也没有按预期工作,即使我设法让它工作,prerender不工作.有没有其他解决方案或我必须等待?
我已经完成了对我的应用程序的编码,并尝试将其构建为生产模式,并且在测试了该应用程序之后,我看到图像未在应用程序中显示为徽标...但是在开发模式下还可以。这是我的项目的树:
是否需要将webpack添加到我的项目中以解决此问题?
我还想问一下webpack的功能,因为我的项目不包括webpack,我发现有必要将它用作我的应用程序。
在angular-cli工具中,存在环境文件。您可以在配置文件中指定它们,例如:
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
Run Code Online (Sandbox Code Playgroud)
在项目中要使用环境变量的任何地方,您所要做的就是包括基础environment.ts文件。然后,根据构建环境,您可以使用ng build --prod,例如使用,文件引用可能会更改(因此,对于prod,它将使用environment.prod.ts代替environment.ts)。
我正在尝试通过Webpack配置实现相同的功能,但不知道如何实现此目的。
谁能举例说明如何基于Webpack中的环境配置这种动态文件引用?
谢谢!
我正在使用Angular CLI,当我运行时ng test,它开始启动浏览器,然后突然出现错误:
userName@UserName:~/devApp/profiles$ng test
10% building modules 1/1 modules 0 active18 09 2017 16:16:51.891:WARN [karma]: No captured browser, open http://localhost:9876/
18 09 2017 16:16:51.903:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
18 09 2017 16:16:51.903:INFO [launcher]: Launching browser Chrome with unlimited concurrency
18 09 2017 16:16:51.915:INFO [launcher]: Starting browser Chrome
ERROR in Entry module not found: Error: Can't resolve '/Users/xxx/devApp/profiles/src/test.ts' in '/Users/xxx/devApp/profiles/node_modules/@angular/cli/models/webpack-configs'
Run Code Online (Sandbox Code Playgroud)
这是文件:test.ts当我设置项目时通过Angular CLI生成的文件:
// This file is required by karma.conf.js and loads recursively all …Run Code Online (Sandbox Code Playgroud) 我正在将现有的AngularJS应用程序转换为混合应用程序,开始逐步将其升级到Angular 4.我想了解Angular 4如何在现有的AngularJS中引用.在现有的AngularJS应用程序中,很清楚如何加载AngularJS框架 - 它只是一个包含的脚本文件:
<script src="/angular/angular.js"></script>
Run Code Online (Sandbox Code Playgroud)
为了熟悉最新的Angular版本,我使用https://angular.io/guide/quickstart上的Angular快速入门指南创建了一个单独的"快速入门"Angular 5应用程序,我可以使用以下命令运行它:
ng serve --open
Run Code Online (Sandbox Code Playgroud)
当我查看项目文件时,我没有看到角度框架实际加载的位置.该应用程序的src/index.html文件中没有任何脚本,它只是声明一个组件(app.component.ts)的指令,如下所示:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Test Angular 5 app';
}
Run Code Online (Sandbox Code Playgroud)
导入实际从哪里导入?Angular文档说明了它的index.html文件:
有人访问您的网站时提供的主HTML页面.大多数情况下,您永远不需要编辑它.在构建应用程序时,CLI会自动添加所有js和css文件,因此您无需手动添加任何或标记.
那么这里发生了什么?@ angular/core实际上是如何被引用的?
使用Angular cli v5和angularfire2 v5,在控制台和终端上没有错误,它们都运行良好,但是在调用google登录功能时却在浏览器控制台上出错。
源代码 :
import { Component, OnInit, HostBinding } from '@angular/core';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';
import { Router } from '@angular/router';
import { moveIn } from '../router.animations';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css'],
providers: [AngularFireAuth],
animations: [moveIn()],
host: {'[@moveIn]': ''}
})
export class LoginComponent implements OnInit {
error: any;
constructor(public afAuth: AngularFireAuth) { }
loginGoogle() {
this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
}
logout() {
this.afAuth.auth.signOut();
}
ngOnInit() { }
}
Run Code Online (Sandbox Code Playgroud) google-oauth firebase-authentication angular-cli angularfire2 angular
在Angular 5中,我注意到ng serveVisual Studio Code中的命令具有以下奇怪行为,导致第一次编译与后续编译的结果不同。
[ts] Property 'x' does not exist on type 'y'.ng serve并按Enter键时,控制台将显示TypeScript错误,然后显示消息webpack: Failed to compile。CTRL + S,则会忽略TypeScript错误,并显示以下消息:webpack: Compiled successfully。这是我一段时间以来注意到的。第一次编译应用程序时,如果出现TypeScript错误,它将失败。但是,在由后续保存触发的编译中,尽管存在这些错误,该应用程序仍可以成功编译。
为什么会这样?有没有解决的办法,或者这是预期的行为?
在我的package.json文件中,我有:
"scripts": {
"start": "concurrently \"ng serve --host something.mydomain.com --port 4200 --live-reload false --env=prod\" \"gulp\""
},
Run Code Online (Sandbox Code Playgroud)
当我运行时npm start,几秒钟后,我可以在浏览器中访问我的项目,网址为http://something.mydomain.com:4200
我希望直接访问https://something.mydomain.com(即不带端口号)来访问同一系统
我已经将package.json修改为:
"scripts": {
"start": "concurrently \"ng serve --host something.mydomain.com --port 80 --live-reload false --env=prod\" \"gulp\""
},
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时package.json我得到:
端口80已在使用中。使用'--port'指定其他端口。
如果我运行,lsof -i :80则什么也不会发生,因此我确定未占用端口80。我怀疑问题在于端口80是受保护的端口,并且在我登录时ec2-user没有正确的权限吗?
如何通过端口80运行我的项目?
angular-cli ×10
angular ×9
javascript ×2
typescript ×2
amazon-ec2 ×1
angular5 ×1
angularfire2 ×1
electron ×1
google-oauth ×1
image ×1
unit-testing ×1
universal ×1
vagrant ×1
webpack ×1
webpack-2 ×1