我用angular-cli创建了角度2项目.我创建了单独的AppRoutingModule,它导出了RouterModule并被添加到AppModule进口数组中.
我还有由angular-cli创建的appComponent.
app.component.html
<nav>
<a *ngFor="let view of views" routerLink="{{ view.address }}" routerLinkActive="active">{{ view.text }}</a>
</nav>
<router-outlet></router-outlet>
Run Code Online (Sandbox Code Playgroud)
app.component.spec.ts
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('App: AquaparkFrontend', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
});
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have 3 views`, () => { …Run Code Online (Sandbox Code Playgroud) 示例文档:
{
"_id" : "5fTTdZhhLkFXpKvPY",
"name" : "example",
"usersActivities" : [
{
"userId" : "kHaM8hL3E3As7zkc5",
"startDate" : ISODate("2015-06-01T00:00:00.000Z"),
"endDate" : ISODate("2015-06-01T00:00:00.000Z")
}
]
}
Run Code Online (Sandbox Code Playgroud)
我是mongoDB的新手,我读了有关更新嵌套数组的其他问题,我无法正确完成.我想要做的是为给定userId的用户更改startDate和endDate.我的问题是它始终将新对象推送到数组而不是使用给定的userId更改对象.
Activity.update(
_id: activityId, usersActivities: {
$elemMatch: {
userId: Meteor.userId()
}
}},
{
$push: {
'usersActivities.$.startDate': start,
'usersActivities.$.endDate': end
}
}
);
Run Code Online (Sandbox Code Playgroud)
我很乐意帮忙.
我尝试在我的应用程序中模拟请求,但是流程变量存在问题.我将process.env.backendUrl url存储在后端API中.然后在RestService我有:
constructor(private http: Http) {
this.rest = process.env.backendUrl + "/api/";
}
Run Code Online (Sandbox Code Playgroud)
现在不可能运行测试,因为在例如LoginComponent我有RestService依赖,我有这个错误:
zone.js:140 Uncaught Error: Error in ./LoginComponent class LoginComponent_Host - inline template:0:0 caused by: process is not defined
ReferenceError: process is not defined
at new RestService (http://localhost:9876/base/src/test.ts:21595:2790)
at DynamicTestModuleInjector.get (DynamicTestModule.ngfactory.js:170:67)
at DynamicTestModuleInjector.get (DynamicTestModule.ngfactory.js:180:93)
at DynamicTestModuleInjector.getInternal (DynamicTestModule.ngfactory.js:255:51)
at DynamicTestModuleInjector.NgModuleInjector.get (http://localhost:9876/base/src/test.ts:25036:27)
at TestBed.get (http://localhost:9876/base/src/test.ts:5589:51)
at _View_LoginComponent_Host0.createInternal (LoginComponent_Host.ngfactory.js:16:74)
at _View_LoginComponent_Host0.AppView.create (http://localhost:9876/base/src/test.ts:36192:21)
at _View_LoginComponent_Host0.DebugAppView.create (http://localhost:9876/base/src/test.ts:36404:44)
Run Code Online (Sandbox Code Playgroud)
我在enviroment.ts(由angular-cli创建的文件)中设置了proccess.env.backendUrl.
process.env.backendUrl = 'http://localhost:8080';
export const environment = {
production: false
};
Run Code Online (Sandbox Code Playgroud)
我应该将它设置在其他地方还是有任何方法可以告诉业力这个变量?