小编red*_*der的帖子

为什么我不将任何参数传递给地图中的函数?

为什么我们不必function b 在下面的代码中传递参数?是因为我们使用的是Array类型的map方法吗?或者在JavaScript中我们可以在其他任何地方使用这样的函数吗?

有人能给出一个非常干净的解释吗?

码:

/* we have an array a*/
const a = ['a', 'b', 'c'];
/*we define a function called b to process a single element*/
const b = function(x){do something here};
/*I noticed that if we want to use function b to take care with the 
elements in array a. we just need to do the following.*/
a.map(b);
Run Code Online (Sandbox Code Playgroud)

javascript arrays

4
推荐指数
2
解决办法
928
查看次数

没有平台提供商

所以我在为 Angular 4 应用程序进行单元测试时遇到了这个问题

发生的情况是它不断给出问题标题中所述的错误。

我尝试用谷歌搜索它,尝试导入一大堆不同的模块,最后发现这个“平台”的接近答案可能是@angular/browser平台中的 browserModule 。

因此,在我的单元测试中,我尝试导入它并声明它,但没有帮助。

任何人都可以帮忙解决这个问题,因为我什至不确定这个“平台”是什么?

问题:错误中的这个“平台”到底是什么以及如何修复它?

谢谢。

我已附上我的代码如下:

import { ComponentFixture, TestBed, async} from "@angular/core/testing";
import { DebugElement, CUSTOM_ELEMENTS_SCHEMA, PlatformRef} from 
"@angular/core";
import { TeamCreationAssignmentComponent } from "./team-creation-assignment.component";
import { OdmService } from "../../services/odm/odm.service";
import { UserNotificationService } from "../../services/user/user-notification.service";
import { MatSnackBar } from "@angular/material";
import { OVERLAY_PROVIDERS, ScrollStrategyOptions, ScrollDispatcher} from "@angular/cdk/overlay";

describe('Team creation assignment component', () => {
let comp: TeamCreationAssignmentComponent;
let fixture: ComponentFixture<TeamCreationAssignmentComponent>;

let odmServiceSub = {};


beforeEach(async(() => { …
Run Code Online (Sandbox Code Playgroud)

javascript angular-material angular angular-cdk

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