小编Gab*_*iel的帖子

在WebStorm中的导入和大括号之间添加空格

是否可以在WebStorm的自动导入功能中在导入和大括号之间添加空格?

目前自动导入的方式如下:

import {AbstractControl} from '@angular/forms';
Run Code Online (Sandbox Code Playgroud)

我想将其更改为:

import { AbstractControl } from '@angular/forms';
Run Code Online (Sandbox Code Playgroud)

webstorm

44
推荐指数
4
解决办法
9531
查看次数

检查firebase DB中是否存在值

firebase中是否有方法可以检查DB中是否存在值?Firebase有方法.exists(),但根据文档,它只检查键.

我有以下结构:

{
  "users": {
    "-KKUmYgLYREWCnWeHCvO": {
      "fName": "Peter",
      "ID": "U1EL9SSUQ",
      "username": "peter01"
    },
    "-KKUmYgLYREWCnWeHCvO": {
      "fName": "John",
      "ID": "U1EL5623",
      "username": "john.doe"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我想检查是否U1EL5623存在具有值的ID .

javascript firebase firebase-realtime-database

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

VS代码中的文件路径自动完成

VS Code是文件路径的自动完成功能吗?例如,如果我想写js的完整路径:"assets/libs/jquery.min.js" 像Brackets.ie这样的编辑器默认情况下这样做.

visual-studio-code

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

如何在Angular Material2中获取活动选项卡

我想获得哪个标签处于活动状态.我尝试使用@ViewChild装饰器并以这种方式访问​​元素属性,但它返回null.

零件:

import {Component, OnInit, ViewChild} from '@angular/core';

@Component({
  selector: 'material-app',
  template: `
  <md-tab-group #tabGroup>
      <md-tab label="Tab 1">Content 1</md-tab>
      <md-tab label="Tab 2">Content 2</md-tab>
  </md-tab-group>
  `
})
export class AppComponent implements OnInit {

  @ViewChild('tabGroup') tabGroup;

  constructor() {
  }

  ngOnInit() {
    console.log(this.tabGroup); // MdTabGroup Object
    console.log(this.tabGroup.selectedIndex); // null
  }

}
Run Code Online (Sandbox Code Playgroud)

Plunker预览

angular-material2 angular

23
推荐指数
3
解决办法
4万
查看次数

将方法作为参数传递给小部件

我有一个自定义按钮小部件:

class Button extends StatelessWidget {
  final String text;

  Button(this.text);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 50,
      child: SizedBox(
        width: double.infinity,
        child: RaisedButton(
          onPressed: () => {}, // Use the function from parent Widget
          child: Padding(
              padding: EdgeInsets.symmetric(vertical: 13),
              child: Text(
                text,
                style: TextStyle(fontWeight: FontWeight.bold),
              )),
          color: COLOR_BLUE,
          textColor: Colors.white,
          shape:
              RoundedRectangleBorder(borderRadius: BorderRadius.circular(25)),
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

然后在父小部件中,我想将一个onPressed方法传递给这个按钮小部件:

...
myMethod () => {
   // do some stuff
}
...
Padding(
    padding: EdgeInsets.only(bottom: 10),
    child: Button("Log …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

Angular6 - >构建错误

我曾经用命令构建我的角度5项目:

ng build --prod --locale=de --base-href /onlineshopNP/de/ -op dist/de
Run Code Online (Sandbox Code Playgroud)

我已将我的项目更新为angular 6,当我调用该命令时,我收到如下错误:

模式验证失败,出现以下错误:数据路径""不应具有其他属性(o).错误:架构验证失败,并出现以下错误:数据路径""不应具有其他属性(o).在MergeMapSubscriber.registry.compile.pipe.operators_1.concatMap.validatorResult [作为项目](C:\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\architect\src\architect.js:218 :39)在MergeMapSubscriber._next的MergeMapSubscriber._tryNext(C:\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\_comchitect + node_modules\rxjs\operators\mergeMap.js:122:27) MergeMapSubscriber.Subscriber.next(C:\ Users)中的(C:\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\_comchitect + node_modules\rxjs\operators\mergeMap.js:112:18)\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\architect \node_modules\rxjs\Subscriber.js:90:18)at MergeMapSubscriber.notifyNext(C:\ Users\martin.kuenz\Documents\Angular \在InnerSubscriber._next(C:\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-)的webshop \node_modules\@ angular-devkit\_comchitect + node_modules\rxjs\operators\mergeMap.js:145:30)的devkit \建筑\node_modules\r xjs\InnerSubscriber.js:23:21)在InnerSubscriber.Subscriber.next(C:\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\_comchitect + node_modules\rxjs\Subscriber.js:90 :18)在SafeSubscriber.next(C)的SafeSubscriber .__ tryOrSetError(C:\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\core \node_modules\rxjs\Subscriber.js:248:16) :\ Users\martin.kuenz\Documents\Angular\webshop \node_modules\@ angular-devkit\core \node_modules\rxjs\Subscriber.js:188:27)at MapSubscriber._next(C:\ Users\martin.kuenz\Documents \角\网店\node_modules\@角的devkit \芯\node_modules\rxjs \运营\ map.js:85:26)

有谁能够帮我?

谢谢

angular-cli angular angular6

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

使用Emmet将URL添加到<a href="">中

Emmet是否有添加URL<a href="">标记的语法?

例如:

句法:

a:www.google.com
Run Code Online (Sandbox Code Playgroud)

结果:

<a href="www.google.com"></a>
Run Code Online (Sandbox Code Playgroud)

html emmet

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

SingleChildScrollView 内的全高容器

我有一个SingleChildScrollView,里面有一个Container。我想要实现的是Container's高度应该是完整的视口高度。

我的代码:

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'MyApp',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        fontFamily: 'OpenSans',
      ),
      home: SingleChildScrollView(
        child: Container(
          color: Colors.white,
          height: double.infinity,
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

如果我运行我的代码,我有一个例外:

I/flutter ( 6293): ??? EXCEPTION CAUGHT BY RENDERING LIBRARY ??????????????????????????????????????????????????????????
I/flutter ( 6293): The following assertion was thrown during performLayout():
I/flutter ( 6293): BoxConstraints forces an infinite height.
I/flutter ( 6293): These invalid constraints were …
Run Code Online (Sandbox Code Playgroud)

flutter

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

如何模拟模拟服务的 getter 参数值

我已经尝试过这个SO,但这不是我的情况。

我有一个服务 ( AnimationService),它依赖于另一个服务 ( AnimationStateService)。它AnimationStateService有一个 getter state,我想在测试中模拟它。所以我的测试看起来像这样:

动画.服务.规格.ts

describe("AnimationService", () => {

let animationService: SpyObj<AnimationService>;
let animationStateService: SpyObj<AnimationStateService>;

beforeEach(() => {

    const spyAnimationStateService = createSpyObj("AnimationStateService", ["changeStatus"]);

    TestBed.configureTestingModule({
        providers: [
            AnimationService,
            {provide: AnimationStateService, useValue: spyAnimationStateService}
        ]
    });

    animationStateService = TestBed.get(AnimationStateService);
    animationService = TestBed.get(AnimationService);
});

fit("should call changeStatus if status is AnimationStatus.Stopped", () => {
    // Arrange
    // animationStateService.status.and.returnValue(AnimationStatus.Stopped); - Doesn't work
    // spyOnProperty(animationStateService, "status").and.returnValue(AnimationStatus.Stopped); - Doesn't work
    // animationStateService.status = AnimationStatus.Stopped; - Works, …
Run Code Online (Sandbox Code Playgroud)

unit-testing mocking jasmine typescript angular

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

delay何时不推荐使用RxJs

Deprecated symbol used ...在IDE中收到一条警告,要求delayWhen在我的应用程序中使用它。

在此处输入图片说明

我的代码:

private nextImg(): Observable<void> {
    return this.stream$.pipe(
          delayWhen(() => timer(1000),
          tap(() => this.subject.next(NEXT_IMG)),
         );
}
Run Code Online (Sandbox Code Playgroud)

我检查了源代码中的delayWhen操作者和文档,以及,但我无法找到,而不是使用什么delayWhen。任何的想法?

intellij-idea deprecated rxjs

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