标签: angular6

Angular`ng update @angular/...`返回`401 Unauthorized`

npm -v 回报 6.0.0

node -v 回报 v10.0.0

Angular CLI本地和全局版本是 6.0.0

我创建了一个新的包ng new sample,运行npm install没有问题,然后我尝试ng update @angular/core或ng update @angular/cli得到401 Unauthorized回应.

尝试在已经安装的Angular 6存储库上运行更新似乎是多余的,但我对Angular 5存储库也有这个问题.

ng5-sample git:(ng6)更新@ angular/core,401 Unauthorized

我没有太多可以从这个错误中继续下去,它是专门做的事情ng update还是更有可能是它之外的一些不相关的配置?

angular-cli angular angular6

6
推荐指数
1
解决办法
4857
查看次数

角组件默认样式CSS显示块

我讨厌所有的角度元素都是0x0像素,因为它们具有诸如app-card,app-accordion之类的名称,浏览器无法将其识别为符合HTML5的元素,因此不会提供任何默认样式。

这意味着在Chrome中检查它时,我看不到容器尺寸,并且当DOM真的很深时,很难理解哪个元素包含了屏幕上的哪个区域,等等。

在我看来,所有角度元素默认情况下都应进行块显示,这是合乎逻辑的,因为对于大多数情况而言,这是有道理的。

例如,考虑这些要素

bbs-accordion-header //(width 0px, height 0px)
Run Code Online (Sandbox Code Playgroud)

包含

bbs-accordion-header-regular //(width 1920px, height 153px)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

因此,bbs-accordion-header没有任何尺寸,即使它的孩子确实有它们。

我通过手动向每个元素.scss文件添加一行来解决此问题

:host { display: block; }
Run Code Online (Sandbox Code Playgroud)

但是每次手动添加它都是非常繁琐的。有谁知道更好的解决方案?

angular2-template angular angular5 angular6 angular7

6
推荐指数
1
解决办法
1305
查看次数

无法解码下载的字体,使用nginx部署的Angular 6应用程序上的OTS打包错误

我在ngnix上部署了具有以下结构的角度dist文件夹.但得到Failed to decode downloaded font: host/rfid/fontawesome-webfont.af7ae505a9eed503f8b8.woff2?v=4.7.0; OTS parsing error: invalid version tag错误.

这是我如何包含字体 - 真棒.

的package.json

"dependencies": {
-------
"font-awesome": "^4.7.0",
--------
}
Run Code Online (Sandbox Code Playgroud)

angular.json

"styles": [
-----,
"node_modules/font-awesome/scss/font-awesome.scss",
-----
]
Run Code Online (Sandbox Code Playgroud)

这是我正在部署dist文件夹的路径.

/user/www/data/rfid/dist
Run Code Online (Sandbox Code Playgroud)

以下是我的nginx conf文件default.conf.

proxy_cache_path /tmp/nginx levels=1:2 keys_zone=nginx_cache_zone:10m inactive=60m;
proxy_cache_key "$scheme$request_method$host$request_uri";

client_max_body_size 20M;
proxy_read_timeout 600;

server {
    listen 80 default_server;
    server_name something;
    location /rfid/ {
      alias /user/www/data/rfid/dist/;
      try_files $uri$args $uri$args/ /rfid/index.html;
   }
}
Run Code Online (Sandbox Code Playgroud)

我还要包括我的构建内容.

Angular 6 app dist

我在这里错过了什么?提前致谢.

编辑:如果这是附加到要寻找的文件的URL查询字符串的问题,我还能当我只有指定的依赖并添加SASS文件吗?

nginx angular angular6

6
推荐指数
1
解决办法
3704
查看次数

集成的Web组件在Angular 6中使用了错误的base-href

我刚刚使用Angular 6创建了我的第一个Web组件.一切正常,直到我尝试将Web组件集成到现有应用程序中:

集成了Web组件的应用程序(https://www.example.com):

<script type="text/javascript" src="https://component.example.com/html-imports.min.js"></script>
<link rel="import" href="https://component.example.com/element.html">
<my-web-component uuid="2342-asdf-2342-ffsk"></my-web-component>
Run Code Online (Sandbox Code Playgroud)

我的Web组件index.html不包含base-href.

浏览器现在尝试加载Web组件的资源:

https://www.example.com/assets/i18n/de_CH.json
Run Code Online (Sandbox Code Playgroud)

代替

 https://component.example.com/assets/i18n/de_CH.json
Run Code Online (Sandbox Code Playgroud)

当我尝试在构建期间添加base-href时,会导致:

ng build --configuration=development --base-href https://component.example.com/

Cannot read property 'startTag' of null          
TypeError: Cannot read property 'startTag' of null
    at IndexHtmlWebpackPlugin.<anonymous> (/home/www-data/.../node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js:147:62)
    at Generator.next (<anonymous>)
    at fulfilled (/home/www-data/.../node_modules/@angular-devkit/build-angular/src/angular-cli-files/plugins/index-html-webpack-plugin.js:4:58)
Run Code Online (Sandbox Code Playgroud)

任何帮助都非常感谢,我的想法已经不多了.

web-component angular-cli angular angular6 angular-elements

6
推荐指数
1
解决办法
1730
查看次数

使用Angular 6和Karma进行随机测试失败

我们在CI管道中观察了随机业力测试.在每次运行中,不同的测试失败,有时它会通过,当它失败时会抛出此错误:

Uncaught TypeError: params.map is not a function thrown

有没有人受到类似的影响?

karma-jasmine angular angular6

6
推荐指数
1
解决办法
1897
查看次数

Angular 6儿童路线延迟装载

我必须访问技能路线,这对我来说是不可能的.我已经尝试了很多方法,但是我无法按照代码结构访问技能路线.我的想法是能够访问仪表板模块的子路径

非常感谢你提前.

// app.routing.module.ts

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

// components for route controller 
import { HomeComponent } from './components/home/home.component';

const routes: Routes = [
    { 
        path: '', redirectTo: 'home', pathMatch: 'full' 
    },
    {
        path: 'home', component: HomeComponent
    },
    {
        path: 'dashboard',
        loadChildren: '../app/modules/dashboard/dashboard.module#DashboardModule'
    }

];

@NgModule({
    imports: [RouterModule.forRoot(routes)],
    exports: [RouterModule]
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)

....

// dashboard.routing.module.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from …
Run Code Online (Sandbox Code Playgroud)

routing lazy-loading angular6

6
推荐指数
1
解决办法
1355
查看次数

routerLink在Angular 6中不起作用

我正在学习Angular 6.

我以层次结构形式设计了我的应用程序结构,结构如下.

my_app
 |- src
    |- app
       |- layout
          |- admin-layout
             |- admin-layout.module.ts
             |- admin-layout.routing.ts
             |- admin-layout.component.html
       |- contacts
          |- contact-list
             |- contact-list.component.ts
             |- contact-list.component.html
          |- contacts.module.ts
       |- transaction
          |- amount-given
             |- amount-given-list
                |- amount-given-list.component.ts
                |- amount-given-list.component.html
             |- amount-given.module.ts
             |- amount-given.routing.ts
             |- amount-given.service.ts
          |- transaction.module.ts
          |- transaction.routing.ts
       |- app.module.ts
       |- app.component.html
       |- app-routing.module.ts
Run Code Online (Sandbox Code Playgroud)

源代码和演示图可以在这里找到:https: //stackblitz.com/edit/angular-wcglvr

<a routerLink="/dashboard">Dashboard</a>
Run Code Online (Sandbox Code Playgroud)

是工作,/transaction/amount-given/amount-given-list/但不是从/contacts/contact-list.

由于源代码很长且层次分明,我在stackblitz上添加了演示插图.

angular angular6

6
推荐指数
2
解决办法
7606
查看次数

角材料组件不起作用:'mat-option'不是一个已知元素

我正在尝试添加角形材质组件。但该组件无法正常工作。该错误说

Uncaught Error: Template parse errors: 'mat-option' is not a known element:
// ...
Run Code Online (Sandbox Code Playgroud)

我认为错误来自app.module.ts:

Uncaught Error: Template parse errors: 'mat-option' is not a known element:
// ...
Run Code Online (Sandbox Code Playgroud)

typescript angular-material angular angular6

6
推荐指数
1
解决办法
8710
查看次数

如何在ng2-smart-table的下拉列表中设置多个选择?

在我的应用程序中,我在ng2-smart-table的下拉列表中加载了动态值.现在我必须在ng2-smart-table中的下拉列表中启用多个选择.

注意:下拉列表中的多项选择不是复选框.

ng2-smart-table angular6

6
推荐指数
1
解决办法
2329
查看次数

如何在角度6中赋予会话空闲超时?

我们正在根据用户角色维护会话。我们想在会话空闲5分钟时实现超时功能。我们正在使用@ ng-idle / core npm模块来做到这一点。

我的服务文件:

 import { ActivatedRouteSnapshot } from '@angular/router';
 import { RouterStateSnapshot } from '@angular/router';
 import {Idle, DEFAULT_INTERRUPTSOURCES, EventTargetInterruptSource} from 
 '@ng-idle/core';
 @Injectable()
export class LoginActService implements CanActivate {
constructor(private authService: APILogService, private router: 
 Router,private idle: Idle) {
  idle.setIdle(10);
  idle.setTimeout(10);
 }
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
 ): Observable<boolean>|Promise<boolean>|boolean {
let role = localStorage.getItem('currentUser');

if (localStorage.getItem('currentUser')) {
  if(next.data[0] == role){
   },600000) 
    return true;
  } 
}
else{
  this.router.navigate(['/'], { queryParams: { returnUrl: state.url }});
  return false;
  }
 }
}
Run Code Online (Sandbox Code Playgroud)

作为示例,我使用了setIdle超时5秒钟,但这没有发生。有人可以指导我该怎么做吗?

session angular angular6

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