如果我扩展本地导出的类,它就可以工作。
工作示例:
export class classA {
constructor() {
super();
}
}
export class classB extends classA {
constructor() {
super();
this.do();
}
private do(): void {
// do something
}
Run Code Online (Sandbox Code Playgroud)
但是当我从文件外部导入 classA 时,它不起作用。
不工作的例子:
import { classA } from '../'; // I use index.ts file, so the reference is good.
export class classB extends classA {
constructor() {
super();
this.do();
}
private do(): void {
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
文件结构:
Root/
- index.ts
- classA(folder)/
- index.ts
- classA.ts …Run Code Online (Sandbox Code Playgroud) 所以,现在我有很多打开的应用程序,通常是 3-4 个 powershell 控制台。我可以命令 powershell 窗口一起观看它们(左上角、右上角、左下角、右下角)。
所以这意味着如果我切换到另一个应用程序,当我切换回来时,我必须恢复所有多个 powershell 窗口才能再次看到它们。
我想要的是,为许多 powershell 创建一个“共享窗口”,因为当我需要一个时,我需要所有的人都能看到。
有没有办法做到这一点?
如何获取当前路由器出口组件的静态路由路径,路由器事件中的角度激活了什么?
我在app.component 中需要它,因为如果我必须在所有组件中使用activatedRoute.snapshot 进行操作,那将是多余的
self.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
//I need here the path of route E.G '/page/:id/' from root
}
});
Run Code Online (Sandbox Code Playgroud)
更新:在路由中:
export const MAIN_ROUTES: Routes = [
{ path: '', component: HomePage },
{ path: 'something', component: SomethingComponent },
{ path: 'page/:id', component: PageComponent }, //if the url is 'example.com/page/someId' than, I want to get the "path" field of this object and if I change the page, I need that inside the router event above. …Run Code Online (Sandbox Code Playgroud) 我想创建一个包含组的对象,并且组有文件。可选择的文件有一个界面,如果一个组不包含其文件,我想得到错误。
export interface Group_A_Files {
'movie': string
'image': string
'other': string
}
export interface Group_B_Files {
'image': string
}
export const groups = {
'groupA' : {
'someField': 'some value',
'files': <Group_A_Files> {
'movie': '',
'image': '',
} // I want to get an error from the IDE, because other is required in Group_A_Files, but not set by me
},
'groupB' : {
'someField': 'some value',
'files': <Group_B_Files>{
'image': '',
'bla': ''
} // I want to get an error …Run Code Online (Sandbox Code Playgroud) 我只是在想我们需要使用await 运算符,以及以下两种情况有什么区别。
一
public async updateOne(Model, doc, errorMsg?){
return await Model.findOneAndUpdate({'_id': doc._id}, {'$set': doc}, {upsert:true, new: true}).lean().exec();
}
Run Code Online (Sandbox Code Playgroud)
二
public updateOne(Model, doc, errorMsg?){
return Model.findOneAndUpdate({'_id': doc._id}, {'$set': doc}, {upsert:true, new: true}).lean().exec();
}
Run Code Online (Sandbox Code Playgroud)
我认为结果没有什么区别,但我认为完全没有必要使用 async wait,因为会返回一个 Promise,而我们只需要在 async 函数内调用 updateOne 函数时使用 await 运算符。