小编sel*_*ect的帖子

使用routerLink进行Angular 2单元测试组件

我试图用angular 2 final测试我的组件,但是我得到一个错误,因为组件使用了该routerLink指令.我收到以下错误:

无法绑定到'routerLink',因为它不是'a'的已知属性.

这是ListComponent模板的相关代码

<a 
  *ngFor="let item of data.list" 
  class="box"
  routerLink="/settings/{{collectionName}}/edit/{{item._id}}">
Run Code Online (Sandbox Code Playgroud)

这是我的考验.

import { TestBed } from '@angular/core/testing';

import { ListComponent } from './list.component';
import { defaultData, collectionName } from '../../config';
import { initialState } from '../../reducers/reducer';


const data = {
  sort: initialState.sort,
  list: [defaultData, defaultData],
};

describe(`${collectionName} ListComponent`, () => {
  let fixture;
  beforeEach(() => {
    TestBed.configureTestingModule({
      declarations: [
        ListComponent,
      ],
    }).compileComponents(); // compile template and css;
    fixture = TestBed.createComponent(ListComponent);
    fixture.componentInstance.data = data;
    fixture.detectChanges(); …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-routing angular2-testing angular

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

用于Observable.of()的RxJS first() - 没有顺序的元素

对于我的测试,我试图模拟一个事件流,Observable.of()但当我尝试

const actions$ = Observable.of({});
...
// in the function that is tested
actions$
  .filter(action => action.type === 'LOAD_REQUEST') 
  .first()
  .subscribe(() => { ... do something });
Run Code Online (Sandbox Code Playgroud)

我收到以下错误

EmptyError:xxx.js中没有按顺序排列的元素

这只在我使用时发生.first().

如何模拟事件流以使测试不会失败?

javascript rxjs ngrx angular

19
推荐指数
2
解决办法
4663
查看次数

rxjs throttle this.durationSelector不是一个函数

我正在尝试throttle用以下代码存储ngrx存储操作更新事件

import 'rxjs/add/operator/throttle'
import { Dispatcher, Store } from '@ngrx/store';
...
static get parameters() {
  return [[Dispatcher]];
}
constructor(actions$) {
...

this.actions$
  .filter(action => action.type === this.Actions[`LOAD_USERS_REQUEST`])
  .throttle(1000 /* ms */)
  .subscribe(() =>
    ...
  );
Run Code Online (Sandbox Code Playgroud)

这引发了我一个错误

在ThrottleSubscriber.tryDurationSelector(throttle.js:80)TypeError:this.durationSelector不是函数

当我.throttle(1000).throttle(() => 1000)它替换时抛出一个不同的错误,清楚地显示油门需要一个功能,而不是我提供的功能.但我想知道为什么因为文档说明油门需要一个数值.

https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/throttle.md

rxjs typescript rxjs5 ngrx angular

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

angular2使用嵌套导入模块的组件

有没有可能有以下结构?

app.component.js

@Component({
    template: '<nav-context></nav-context>'
class AppComponent
Run Code Online (Sandbox Code Playgroud)

app.module.js

@NgModule({
    imports: [CoreModule]
    boostrap: [AppComponent]
Run Code Online (Sandbox Code Playgroud)

core.module.js

@NgModule({
    imports: [NavModule]
class CoreModule
Run Code Online (Sandbox Code Playgroud)

nav.module.js

@NgModule({
    declarations: [NavContextComponent]
    exports: [NavContextComponent]
class NavModule
Run Code Online (Sandbox Code Playgroud)

NAV-context.component.js

@Component({
    selector: 'nav-context'
class NavContextComponent
Run Code Online (Sandbox Code Playgroud)

到目前为止我得到了 'nav-context' is not a known element

typescript angular

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

/components/parameters 中的 openApi 3 allOf

我正在尝试使用 open api 3 创建一个 swagger 文档,但是当我尝试allOf在参数定义中使用关键字时出现错误

components:
  parameters:
    idParam:
      name: id
      in: path
      description: ID of the boxx
      required: true
      schema:
        type: string
        format: int65
    dataSourceID:
      allOf:
        - $ref: '#/components/parameters/idParam'
        - name: dataSourceID
          description: ID of the data source
Run Code Online (Sandbox Code Playgroud)

components.parameters['dataSourceID'] 处的架构错误

不应该有额外的属性

附加属性:allOf

是否可以重用另一个参数的值?也许以不同的方式?

swagger swagger-editor openapi

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

对特殊字符使用 replaceText 的问题:[ ]

我想用“[1]”和向后替换“\cite{foo123a}”。到目前为止,我能够用以下命令替换文本

body.replaceText('.cite{foo}', '[1]');
Run Code Online (Sandbox Code Playgroud)

但我没有设法使用

body.replaceText('\cite{foo}', '[1]');
body.replaceText('\\cite{foo}', '[1]');
Run Code Online (Sandbox Code Playgroud)

为什么?

我根本无法工作的反向转换

body.replaceText('[1]', '\\cite{foo}');
Run Code Online (Sandbox Code Playgroud)

这将仅替换“1”而不是 [],这意味着 [] 被解释为正则表达式字符集,转义它们无济于事

body.replaceText('\[1\]', '\\cite{foo}');//no effect, still a char set
body.replaceText('/\[1\]/', '\\cite{foo}');//no matches
Run Code Online (Sandbox Code Playgroud)

该文件指出

不完全支持 JavaScript 正则表达式功能的子集,例如捕获组和模式修饰符。

我可以找到支持哪些内容以及不支持哪些内容的完整说明吗?

google-docs google-apps-script

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