在login.component.ts中声明loginObj,如下所示
public loginObj: Object = {
email:'',
password:''
};
public registerObj: Object = {
email:'',
name:'',
password:''
};
Run Code Online (Sandbox Code Playgroud)
HTML
<input placeholder="" type="text" [(ngModel)]="loginObj.email" autofocus="true" required>
<input placeholder="" type="text" [(ngModel)]="loginObj.password" autofocus="true" required>
Run Code Online (Sandbox Code Playgroud) 我用一个新项目对此进行了测试,没有什么独特的.
ng new debug-project
然后我在头部添加了一些标签,导致了这一点.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DebugProject</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="user-scalable=no, width=device-width" />
<meta name="viewport" content="width=device-width" />
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
<meta name="viewport" content="width=device-width; initial-scale=1; minimum-scale=1; maximum-scale=1; user-scalable=0">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
之后ng build --prod,html现在看起来像这样,浏览器无法读取.注意viewport元标记值中缺少的空格.width, initial-scale=1成为width,initial-scale=1.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DebugProject</title>
<base href="/">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="viewport" content="user-scalable=no,width=device-width" />
<meta name="viewport" content="width=device-width" …Run Code Online (Sandbox Code Playgroud) 我将 Angular 应用程序部署到https域中。API 域是http.
当我使用构建我的 Angular 应用程序时,--prod我在请求中遇到了错误Referrer Policy: strict-origin-when-cross-origin,但是当我在没有--prod请求的情况下构建时,请求工作正常。
有任何想法吗?
我在部署角度应用程序时遇到问题。如果部署的话,它不会发生在另一台计算机上。我的应用程序未运行,并且在 Chrome 上显示以下错误:
不允许加载本地资源
在 Mozilla 中:
元素的“src”属性不是有效的 URI
问题是,如果从其他机器部署它,它工作得完全正常。所以我猜测问题出在 node 或 typescript 或 ng 或其他版本上。我是服务器部署新手,这种问题对我来说是新的。
我使用以下命令来生成部署文件夹:
ng build --prod --base-href /candidate/
Run Code Online (Sandbox Code Playgroud)
以下是我的版本详细信息:
节点版本: v10.16.3
应用typescirpt版本: Version 2.9.2
机器上全局安装的 typescript 版本: Version 3.6.3
我在生产构建之前删除node modules并package-lock.json归档并运行。npm install我没有收到错误并且成功生成dist文件夹。
如果部署文件夹是从已安装升级或降级节点版本的计算机部署的,则部署文件夹可以完美运行。
我发现了许多关于浏览器上显示的错误的建议,尝试升级节点全局版本,但没有办法解决。我很不确定我在这里缺少什么。在这种情况下,任何形式的提醒都会很好。
我有一个 Angular 应用程序,它似乎不是使用产品配置构建的。我收到以下错误:
Index html generation failed.
undefined:9:219187: property missing ':'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! JI.Infopool.WebApp@0.0.0 build: `ng build --outputHashing=all "--configuration=prod"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the JI.Infopool.WebApp@0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Run Code Online (Sandbox Code Playgroud)
正常的构建工作正常,我认为我没有更改任何运行配置。我在日志文件中也找不到任何有用的内容。这是 angular.json 文件中的配置:
"prod": {
"baseHref": "/myApp/",
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false, …Run Code Online (Sandbox Code Playgroud) 在尝试使用我的应用程序时ng-build,我收到以下错误:
试图找到引导代码,但不能.指定静态可分析引导代码或将entryModule传递给plugins选项.
我指定的主文件.angular-cli.json非常简单:
import { NgModule } from '@angular/core';
import { LoginComponent } from './login.component';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
import { HttpClientModule } from '@angular/common/http';
import { LoginService } from '../login.service'
@NgModule({
declarations: [
LoginComponent
],
imports: [
BrowserModule,
FormsModule,
HttpClientModule
],
providers: [LoginService],
bootstrap: [LoginComponent]
})
export class AppModule { }
platformBrowserDynamic().bootstrapModule(AppModule);
Run Code Online (Sandbox Code Playgroud)
ng --version 返回以下内容:
Angular CLI: 1.7.0
Node: 6.11.0
OS: …Run Code Online (Sandbox Code Playgroud) 重新加载发布在 gh 页面上的 angular 应用程序时,我收到错误消息。错误是:
404
File not found.
The site configured at this address does not contain the requested file.
Run Code Online (Sandbox Code Playgroud)
我已经使用 ng build --prod 构建了我的应用程序。
Github 存储库: https : //github.com/chirag299051/IceAndFire
Github 页面: https : //chirag299051.github.io/IceAndFire/
我的 app.module.ts 文件包含:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { RouterModule, Routes } from '@angular/router';
import { BookDetailsComponent } …Run Code Online (Sandbox Code Playgroud) 如果我尝试使用ng build --prod --aot构建我的Angular应用程序,我总是遇到此错误:
ERROR in : Illegal state: Could not load the summary for directive RouterOutlet in C:/Path-To-Project/node_modules/@angular/Router/router.d.ts.
如果我使用"ng serve"编译我的项目,我不会收到错误消息.我试图实现延迟加载的几个变种,但每个都导致错误.此外,我试图完全重建应用程序并遵守Angular的所有规范,但我总是回到这个错误消息的相同点.
我的package.json:
{
"name": "Name",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": …Run Code Online (Sandbox Code Playgroud) 是否有可能在开发环境中禁用Webpack块优化或在ng build应用程序中封闭。我面临的一个问题是,每当我对角度(ts,html,css ....)进行单个更改时,重建过程就会非常缓慢。建议我改善它。
我正在将Angular应用程序部署到Netlify。这个应用程式已经部署了许多次,并且没有任何问题。最近,在添加新功能的同时,我将应用程序从Angular 5升级到了7,并升级了许多依赖项。现在,构建失败了,只提供了很少的信息。
在Netlify上,我使用的构建命令是:
ng build --target=development --environment=staging开发人员和
ng build --target=production --environment=prod生产人员。
Netlify上的日志是:
3:54:11 PM: Fetching cached dependencies
3:54:11 PM: Starting to download cache of 99.4MB
3:54:12 PM: Finished downloading cache in 773.818516ms
3:54:12 PM: Starting to extract cache
3:54:17 PM: Finished extracting cache in 4.66127562s
3:54:17 PM: Finished fetching cache in 5.479273794s
3:54:17 PM: Starting to prepare the repo for build
3:54:17 PM: Preparing Git Reference pull/102/head
3:54:18 PM: Starting build script
3:54:18 PM: Installing dependencies
3:54:19 PM: …Run Code Online (Sandbox Code Playgroud) 当我运行我的 Angular 8 应用程序的 prod 版本时,我在控制台中收到此错误。构建运行良好,我已经在我的提供者中包含了所有服务。
我已经运行了以下命令,但没有收到任何错误。
ng build --prod --optimization=false
有什么办法可以判断什么是失败的?即使我注释掉所有提供程序(预计构建失败),我仍然没有收到任何错误。
请让我知道我可以/应该提供哪些其他信息来帮助您。谢谢!
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS, HttpClient } from '@angular/common/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { NavMenuComponent } from './nav-menu/nav-menu.component';
//a bunch more components...
import { AccountModule } …Run Code Online (Sandbox Code Playgroud) ng-build ×11
angular ×10
typescript ×5
angular-cli ×2
node.js ×2
cross-domain ×1
ecmascript-6 ×1
github ×1
github-pages ×1
java ×1
javascript ×1
nginx ×1
webpack ×1