小编Tre*_*tor的帖子

Angular 2 - 链接http请求

我从一个httpService获得一个RxJS Observable,这是来自Angular的实际http.现在,一旦我从中获得了积极的结果,我想处理我得到的下一个http请求this.retrieve().这或多或少是连续请求.有没有更好的方法呢?

return this.httpService.query(data) 
        .map(data => {
            if(data.status > 1)
               this.retrieve().subscribe();
            return data;
});
Run Code Online (Sandbox Code Playgroud)

javascript http rxjs angular

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

Angular 2使用模块构造函数进行设置

我懒加载这个功能模块.它有不同的路由,第一个是默认路由.由于我需要为此功能模块设置菜单,我尝试使用模块构造函数.

它工作得很好,但使用模块设置数据在语义上是否正确?我没有看到有人使用相同方法的任何示例.

import {NgModule}      from '@angular/core';
import {Routes, RouterModule}  from '@angular/router';
import {OverviewComponent} from "@app/$/main/overview.component";
import {DetailComponent} from "@app/$/main/overview.component";
import {MenuService} from "@app/scheme/desk/menu/menu.service";

export const routes:Routes = [
    {
        path: "",
        redirectTo: "overview"
    },
    {
        path: "overview",
        component : OverviewComponent,
    },
    {
        path: "detail",
        component : DetailComponent
    }

];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    declarations:   [OverviewComponent, DetailComponent],
    exports: [RouterModule]
})
export class DeskModule {

    constructor(private menuService:MenuService){

        this.menuService.items = [{
            label: 'Overview',
        },
        {
            label: 'Detail',
        }];

    }

}
Run Code Online (Sandbox Code Playgroud)

angular

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

Angular 4 - 模板继承

我有以下子组件和它的继承父组件:

@Component({
   template: `<p>child</p>`
})
export class EditChildComponent extends EditViewComponent{
   constructor(){
     super();
   }
}



@Component({
   template: `<p>parent</p>`
})
export class EditViewComponent{
   constructor(){
   }
}
Run Code Online (Sandbox Code Playgroud)

现在有没有办法将EditViewComponent的模板放在ChildComponents模板中,就像在嵌套组件中使用ng-content一样?我如何得到以下结果:

<p>parent</p>
<p>child</p>
Run Code Online (Sandbox Code Playgroud)

angular

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

Angular 2 - 从基类继承提供程序

我有以下基本组件。

@Component({
    providers: [PresetService, CollectionService, RecordService]
})
export class BaseComponent{
    constructor(private collectionService:CollectionService, private recordService:RecordService, private presetService:PresetService){
    }
}
Run Code Online (Sandbox Code Playgroud)

现在所有的孩子都应该继承提供者及其实例:

我有以下基本组件。

@Component({ 
})
export class ChildComponent extends BaseComponent{
    constructor(){
        super()
    }
}
Run Code Online (Sandbox Code Playgroud)

这似乎不可能,因为我需要从孩子那里调用 super 。因此,我需要将提供程序实例从子级传递到基础级。家长可以提供实例吗?

angular

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

Vue.js 的 node_modules 规模巨大(初学者问题)

我开始尝试 vue.js。我确实遵循了建议并添加了以下开发依赖项:

"devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
    "@vue/cli-plugin-eslint": "^4.1.0",
    "@vue/cli-plugin-router": "^4.1.0",
    "@vue/cli-plugin-vuex": "^4.1.0",
    "@vue/cli-service": "^4.1.0",
    "@vue/eslint-config-prettier": "^5.0.0",
    "babel-eslint": "^10.0.3",
    "eslint": "^5.16.0",
    "eslint-plugin-prettier": "^3.1.1",
    "eslint-plugin-vue": "^5.0.0",
    "node-sass": "^4.12.0",
    "prettier": "^1.19.1",
    "sass-loader": "^8.0.0",
    "vue-template-compiler": "^2.6.10"
}
Run Code Online (Sandbox Code Playgroud)

这将在node_modules中加载大约910个模块。大小约为 180 MB。当我尝试复制或传输整个项目时,需要一分钟左右的时间来计算一万个文件。对于一个小项目来说这是很长的。

难道我做错了什么?这看起来有很多东西要随身携带。 任何提示表示赞赏。

node.js vue.js

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

标签 统计

angular ×4

http ×1

javascript ×1

node.js ×1

rxjs ×1

vue.js ×1