小编Sur*_*eal的帖子

Angular 2/4存储令牌的位置

我有一个用于生成令牌的休息api,我在角度4客户端使用,但问题是在哪里存储此令牌.

在互联网上,我发现我可以存储在本地存储或cookie中.

所以我的问题是,如果商店令牌是本地存储,例如,我刚刚从另一个浏览器复制了有效令牌,那么我将拥有一个有效的令牌,因此存在任何像这样的存储令牌的安全性,并且基本相同用饼干,或者我错过了一些重要的信息?

cookies token local-storage typescript angular

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

在角材料中切换主题5

我一直在阅读一些关于此的文章,但它们似乎在几种不同的方式上存在冲突.我希望重新创建与最新版角度材料[5.0.0-rc0] 的角度材料文档站点相同的主题切换

我有两个自定义主题,这是custom-theme.scss,并且有light-custom-theme.scss几乎相同,没有mat-dark-theme

@import '~@angular/material/theming';
$custom-theme-primary: mat-palette($mat-blue);
$custom-theme-accent: mat-palette($mat-orange, A200, A100, A400);
$custom-theme-warn: mat-palette($mat-red);
$custom-theme: mat-dark-theme($custom-theme-primary, $custom-theme-accent, $custom-theme-warn);

@include angular-material-theme($custom-theme);
Run Code Online (Sandbox Code Playgroud)

我的styles.scss看起来像这样

@import '~@angular/material/theming';
@include mat-core();
@import 'custom-theme.scss';
@import 'light-custom-theme.scss';
.custom-theme {
  @include angular-material-theme($custom-theme);
}

.light-custom-theme {
  @include angular-material-theme($light-custom-theme);
}
Run Code Online (Sandbox Code Playgroud)

然后在index.html中调用它 <body class="mat-app-background">

当我做一个主题时,一切正常.但我试图在两者之间切换.将两个主题添加到angular-cli.json中,light-custom-theme接管

"styles": [
  "styles.scss",
  "custom-theme.scss",
  "light-custom-theme.scss"
],
Run Code Online (Sandbox Code Playgroud)

我在我的一个组件中有以下代码来处理切换主题

toggleTheme(): void {
  if (this.overlay.classList.contains("custom-theme")) {
    this.overlay.classList.remove("custom-theme");
    this.overlay.classList.add("light-custom-theme");
  } else if (this.overlay.classList.contains("light-custom-theme")) {
    this.overlay.classList.remove("light-custom-theme");
    this.overlay.classList.add("custom-theme");
  } else {
    this.overlay.classList.add("light-custom-theme");
  }
}
Run Code Online (Sandbox Code Playgroud)

但无论何时运行,主题都保持不变.对于它的价值,在overlay.classList中的位置0处已经存在"cdk-overlay-container"对象

0:"cdk-overlay-container"
1:"custom-theme"
length:2
value:"cdk-overlay-container custom-theme" 
Run Code Online (Sandbox Code Playgroud)

我不确定如何调试这个,因为角度材料文档没有给我太多的工作,任何帮助将是赞赏! …

sass angular-material angular angular5

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

Plunker给了我几天前工作的脚本404

几个星期前我做了一个龙头,一切都进展顺利.

然而今天当我再次访问它时,我的脚本会被404s轰炸,对于改变了什么有任何想法?

http://plnkr.co/edit/M2hRaf?p=preview

Chrome控制台输出 这是index.html的样子

<!DOCTYPE html>
<html>

  <head>
    <base href="." />
    <script type="text/javascript" charset="utf-8">
      window.AngularVersionForThisPlunker = 'latest'
    </script>
    <title>angular playground</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="style.css" />
    <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js/dist/zone.js"></script>
    <script src="https://unpkg.com/zone.js/dist/long-stack-trace-zone.js"></script>
    <script src="https://unpkg.com/reflect-metadata@0.1.3/Reflect.js"></script>
    <script src="https://unpkg.com/systemjs@0.19.31/dist/system.js"></script>
    <script src="config.js"></script>
    <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
  </head>

  <body>
    <my-app>
      Loading...
    </my-app>
  </body>

</html>
Run Code Online (Sandbox Code Playgroud)

javascript jsx plunker angular

3
推荐指数
1
解决办法
729
查看次数

在选择(角度4)上添加操作选项

我希望Angular在用户单击特定选项时执行"onEditClick"函数,这是我的代码:

<select class="form-control">
  <option *ngFor="let skill of skills" (click)="onEditClick(skill)" >{{ skill.name }}</option>
</select>
Run Code Online (Sandbox Code Playgroud)

当我点击任何选项时,没有任何反应.

我尝试用表而不是选择它,它工作:

<tbody *ngFor="let skill of skills">
  <td> {{ skill.name }} </td>
<td><button class="btn btn-outline-success" height="20" width="20" (click)="onEditClick(skill)">Edit</button></td>
</tbody>
Run Code Online (Sandbox Code Playgroud)

如何使用Select one进行操作?

typescript angular

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

修改ng2智能表中动作的标题或添加一个新的

我想向 ng2-smart-table 添加新操作或修改(添加、编辑或删除)的标题。我试图添加 ButtonView 但我无法用它重现任何操作。

任何人都可以帮助我吗?

typescript ng2-smart-table angular

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