小编Ton*_*Ngo的帖子

ng build --prod index.html 文件没有生成后?

在生产模式下构建项目后,我将 Angular 7 更新为 8.2.1,dist 文件夹不生成index.html文件

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "paths": {
      "exceljs": [
        "node_modules/exceljs/dist/exceljs.min"
      ]
    },
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],

  }
}
Run Code Online (Sandbox Code Playgroud)

分布/AssetMang/ 角度.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "AssetMang": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": { …
Run Code Online (Sandbox Code Playgroud)

typescript angular

10
推荐指数
1
解决办法
6082
查看次数

Angular RxJS:条件运算符(如果其他)

我试图弄清楚如何将一个简单的条件操作实现为一个可观察的对象。

this.deactivate$
    .pipe(
        filter((canDeactivate) => !canDeactivate),
        switchMap(() => Observable.of(window.confirm("message")))
    );
Run Code Online (Sandbox Code Playgroud)

我想得到的是:

if (canDeactivate) {
    return canDeactivate;
}
else {
    return window.confirm("message");
}
Run Code Online (Sandbox Code Playgroud)

上面代码的第一个问题是,当我过滤发出的值时,不执行其余的运算符,并且流停止填充发出的值。

有任何想法吗?

javascript rxjs single-page-application typescript angular

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

更新 angular-devkit 并失败:Microsoft.AspNetCore.SpaServices[0]

在我的 Angular 8 +.net core 2.2 中,我从 Angular 8.2.1 升级到 8.2.7,之后我在控制台窗口中看到消息:

fail: Microsoft.AspNetCore.SpaServices[0]
      <s> [webpack.Progress] 10% building 1/1 modules 0 active
.......................
fail: Microsoft.AspNetCore.SpaServices[0]
      <s> [webpack.Progress] 98% after emitting

fail: Microsoft.AspNetCore.SpaServices[0]
      <s> [webpack.Progress] 98% after emitting CopyPlugin

fail: Microsoft.AspNetCore.SpaServices[0]
      <s> [webpack.Progress] 98% after emitting angular-compiler

fail: Microsoft.AspNetCore.SpaServices[0]
      <s> [webpack.Progress] 98% after emitting SizeLimitsPlugin

fail: Microsoft.AspNetCore.SpaServices[0]
      <s> [webpack.Progress] 100%

info: Microsoft.AspNetCore.SpaServices[0]
      chunk {main} main.js, main.js.map (main) 451 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 287 kB [initial] [rendered]
chunk {polyfills-es5} …
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript asp.net-core angular

9
推荐指数
1
解决办法
1766
查看次数

找不到模块,因为 tsconfig.json 中提到了路径

我的打字稿代码为 tsconfig.json 中指定的路径提供了以下错误。请指导我解决这个问题。

错误:在 Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) 中找不到模块“流/数学”

文件夹结构

src/flows/Maths.ts

export class Maths {
    public add() {
        console.log('Add method')
    }
}
Run Code Online (Sandbox Code Playgroud)

src/specs/Start.ts

import { Maths } from "@flows/Maths";
new Maths().add();
Run Code Online (Sandbox Code Playgroud)

配置文件

{
  "compilerOptions": {
    /* Basic Options */
    "target": "es5",                          /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
    "module": "commonjs",                     /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
    // "lib": [],                             /* Specify library files to be included in the …
Run Code Online (Sandbox Code Playgroud)

node.js typescript ecmascript-6 protractor angular

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

周视图小时段角度日历

我需要显示时间间隔为 15,可由用户配置。

我尝试了下面的方法,但显示如下:

在此输入图像描述

我需要以 15 或 30 分钟的间隔显示:15:15 - 15:30 - 15:45

html 组件:

<mwl-calendar-week-view [dayStartHour]="8" [dayStartMinute]="0" [precision]="'minutes'" 
[hourSegments]="4" [dayEndHour]="18" [dayEndMinute]="0" 
*ngSwitchCase="'week'" [excludeDays]="[0,6]" [viewDate]="viewDate" 
(viewDateChange)="selectedDay = {date:$event}" [events]="events" 
[refresh]="refresh" (dayClicked)="dayClicked($event.day)" 
(eventClicked)="edit($event.event" (eventTimesChanged)="eventTimesChanged($event)">
</mwl-calendar-week-view>
Run Code Online (Sandbox Code Playgroud)

CSS:

.cal-week-view {

   .cal-hour-segment.cal-after-hour-start .cal-time {
       display: block;
   }
}
Run Code Online (Sandbox Code Playgroud)

html typescript angular angular-calendar

8
推荐指数
1
解决办法
5111
查看次数

在ng serve命令上找不到构建器@ angular-devkit / build-angular:dev-server的实现

此之后,我尝试更新角度CLI ,但现在无法运行我的应用程序。当我尝试运行命令时ng serve,它给了我这个错误:

Could not find the implementation for builder @angular-devkit/build-angular:dev-server
Error: Could not find the implementation for builder @angular-devkit/build-angular:dev-server
    at WorkspaceNodeModulesArchitectHost.resolveBuilder (C:\Users\Lupus\Documents\full-stack-projects\financial-app-ui\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:49:19)
    at ServeCommand.initialize (C:\Users\Lupus\Documents\full-stack-projects\financial-app-ui\node_modules\@angular\cli\models\architect-command.js:135:55)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Run Code Online (Sandbox Code Playgroud)

我已经尝试了所有可能找到的东西。

  • 我尝试使用以下命令手动安装devkit npm install --save-dev @angular-devkit/build-angular
  • 我试图运行命令 npm i --only=dev
  • 我试图运行命令

npm install
ng update
npm update
Run Code Online (Sandbox Code Playgroud)
  • 删除了node_modules文件夹和package-lock.json文件,然后再次运行了所有命令。

没事。跑步ng v给我这个:

Angular CLI: 8.0.3
Node: 10.15.0
OS: win32 x64
Angular: 8.0.1
... …
Run Code Online (Sandbox Code Playgroud)

node.js npm ecmascript-6 angular-cli angular

8
推荐指数
6
解决办法
6542
查看次数

忽略特定操作的控制器路由属性

我的控制器上有很多操作,如果可能的话,我只想将特定路由用于一个操作。我正在寻找一种方法来覆盖在控制器级别定义的路由。

[Route("api/candidate/attached-file")]
public class AttachedFileController : Controller
    {
        //overriding controller route
        [HttpPost("api/candidate/{id}/attached-file")]
        public async Task<IActionResult> AttachFile(string id, [FromBody] AttachedFile file)
        {
            ...
        }

        //using controller route
        [HttpGet("{id}")]
        public ActionResult Get(string id) {}

        [HttpGet]
        public ActionResult GetAll() {}

        ...
    }
Run Code Online (Sandbox Code Playgroud)

c# routing asp.net-core

8
推荐指数
1
解决办法
1921
查看次数

Angular 7/8 - 如何在应用组件中获取 url 参数

我有单点登录,但为了测试,我想从 url 读取值localhost:4200/?id=test&name=testing&email=testing@test.com并将它们传递给应用程序组件中的 API。

将有一个标志,在此基础上我将从 url 读取而不是使用单点登录功能

if (url_enabled == true) {
    getParamsFromUrl()
 } else {
   singleSignOn()
 }
Run Code Online (Sandbox Code Playgroud)

我尝试了 ActivatedRoute,但它似乎不起作用。

我试过了,queryParams, params, url, queryParamsMap但这些似乎都不起作用。我得到的只是空值。

内部应用组件

app.component.ts

 getParamsFromUrl() {
    this._router.events.subscribe((e) => {
      if (e instanceof NavigationEnd) {
        console.log(e.url)
      }
    })
  }

 this.route.queryParams.subscribe(params => {
      console.log(params);
    })
Run Code Online (Sandbox Code Playgroud)

应用程序组件.html

<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

app-routing.module.ts

const routes: Routes = [
  {path:'*/:id', component: AppComponent},
];
Run Code Online (Sandbox Code Playgroud)

我已经尝试了我可以在 stackoverflow 或其他博客上找到的任何内容。有人可以指出我在这里缺少什么吗?

node.js typescript ecmascript-6 angular angular8

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

错误 NG8001:“路由器插座”不是已知元素

错误 NG8001:'router-outlet' 不是已知元素: 1. 如果 'router-outlet' 是一个 Angular 组件,则验证它是否是该模块的一部分。2. 如果'router-outlet' 是一个Web 组件,则将'CUSTOM_ELEMENTS_SCHEMA' 添加到该组件的'@NgModule.schemas' 以抑制此消息。

4   <router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

在我的 app.component 中

<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)

在我的 package.json 中

{
  "name": "auth-table2",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.0.1",
    "@angular/common": "~9.0.1",
    "@angular/compiler": "~9.0.1",
    "@angular/core": "~9.0.1",
    "@angular/forms": "~9.0.1",
    "@angular/platform-browser": "~9.0.1",
    "@angular/platform-browser-dynamic": "~9.0.1",
    "@angular/router": "~9.0.1",
    "@ng-bootstrap/ng-bootstrap": "^6.0.0",
    "@ngrx/store": "^8.6.0",
    "angularfire2": "^5.4.2",
    "bootstrap": "^4.4.1",
    "firebase": "^7.9.1",
    "rxjs": "~6.5.4", …
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript ecmascript-6 angular

8
推荐指数
1
解决办法
1万
查看次数

无法访问hangfire 仪表板

当我尝试访问 localhost:5000/hangfire 时,我被重定向到错误页面(我有一个返回相对状态页面(400,404 等)的控制器)

这是我收到的错误:在此输入图像描述

我想 /hangfire 不存在。它所指的“HandeErrorCode”来自我的控制器。

[Route ("Error/{statusCode}")]
        public IActionResult HandleErrorCode (int statusCode) {
            var statusCodeData = 
HttpContext.Features.Get<IStatusCodeReExecuteFeature> ();

        switch (statusCode) {
            case 404:
                return View("Status404");
            case 401:
                return View("Status401");
            case 400:
                return View("Status400");    
            case 500:
                return View("Status500");
        }

        return View ();
    }
Run Code Online (Sandbox Code Playgroud)

启动.cs

配置服务

services.AddHangfire(configuration=>{
              configuration.UsePostgreSqlStorage(connectionString);
          }); 
Run Code Online (Sandbox Code Playgroud)

配置

app.UseHangfireDashboard("/hangfire");    
      app.UseHangfireServer();
Run Code Online (Sandbox Code Playgroud)

编辑:整个 Startup.cs

public class Startup {
public Startup (IHostingEnvironment env) {

  Console.WriteLine ("startin app {0}, which uses env {1} and has root {2}", env.ApplicationName, env.EnvironmentName, env.ContentRootPath);
  Configuration …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core

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