小编Sak*_*uto的帖子

生成内部模块文件夹

我正在使用基于Angular-CLI骨架的Angular 2应用程序,我习惯用一个目录按模块构建我的src文件夹,并且每个组件都与该模块在同一文件夹中相关.

src
    app
        documents
            document-list.component.ts
            document-list.component.html
            documents.component.ts
            documents.component.html
            document.module.ts
        app.component.ts
        app.module.ts
    main.ts 
Run Code Online (Sandbox Code Playgroud)

现在我正在使用Angular-CLI,我想利用每个功能,但是当我生成一个新组件时,无论如何,当我只想放置它时,它会继续为我的组件创建一个新文件夹在相关文件夹内.

src
    app
        documents
            document-list
                document-list.component.ts
                document-list.component.html
            documents.component.ts
            documents.component.html
            document.module.ts
        app.component.ts
        app.module.ts
    main.ts 
Run Code Online (Sandbox Code Playgroud)

是否有可能保留我以前的结构,这是一种不好的做法吗?该指南建议避免无用的目录深度,所以我有点不安.

angular-cli angular

23
推荐指数
3
解决办法
2万
查看次数

DI与自定义HTTP和ConfigService的循环依赖关系

我正在尝试实现ConfigService以检索项目中正确环境的正确配置.我目前正在遇到循环依赖

(index):28 Error: (SystemJS) Provider parse errors:
    Cannot instantiate cyclic dependency! Http: in NgModule AppModule
    Error: Provider parse errors:
Run Code Online (Sandbox Code Playgroud)

在我看来,我已经探索过代码并且存在问题:

CustomHttp

constructor(backend: XHRBackend, options: RequestOptions, public spinnerService: SpinnerService, public exceptionService: ExceptionService, public configService: ConfigService) 
Run Code Online (Sandbox Code Playgroud)

ExceptionService

constructor(private _notificationService: NotificationService, private _spinnerService: SpinnerService, private _configService: ConfigService, private _router: Router)
Run Code Online (Sandbox Code Playgroud)

的ConfigService

constructor(private http: Http) {}
Run Code Online (Sandbox Code Playgroud)

如您所见,我在此图中说明了一个循环依赖(没有任何好的约定):

在此输入图像描述

我现在的问题是,如何修复它?我听说过,Injector但我不确定我是否真的可以在这种情况下使用它.

提前感谢您的回答.

typescript angular

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

用于<option>,<li>,<td>的Vanilla Custom Element转发器

我目前正在尝试实施转发器,WebComponent以允许公司轻松创建前端而不依赖于任何framework(由架构决定).

这是我目前的代码:

<ul>
    <company-repeat datas='[{"name": "NameValeur", "value": "valeurId"}, {"name": "NameObject", "value": "objectId"}]'>
        <li>${name}</option>
    </company-repeat>
</ul>

<select name="" id="">
    <company-repeat datas='[{"name": "NameValeur", "value": "valeurId"}, {"name": "NameObject", "value": "objectId"}]'>
        <option value="${value}">${name}</option>
    </company-repeat>
</select>
Run Code Online (Sandbox Code Playgroud)

list是正确的工作,因为它似乎没有限制内部允许的标签,但选择不允许customElement company-repeat在其中和通过扩展,打破功能,只是显示<option value="${value}">${name}</option>

这是我的源代码 WebComponent

class CompanyRepeater extends HTMLElement {
    connectedCallback() {
        this.render();
    }

    render() {
        let datas = JSON.parse(this.getAttribute('datas'));
        let elementType = this.getAttribute('element');
        this.template = this.innerHTML;
        console.log(elementType);

        let htmlContent = elementType !== null ? `<${elementType.toLowerCase()}>` : '';

        datas.forEach(elem => …
Run Code Online (Sandbox Code Playgroud)

html javascript dom web-component custom-element

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

如何仅使用$ http.get获取数据

这是我对JSP的回应,我试图从响应中获取数据.

$http.get('url.jsp', data).then(successCallback, errorCallback);
Run Code Online (Sandbox Code Playgroud)

我正面临"数据未定义"

在此输入图像描述

如何仅检索数据?

javascript json angularjs

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

文件上传创建目录ASP.Net core mac os不创建子文件夹

我正在使用 asp.net core 创建一个项目来将文件上传到服务器中的特定位置。

这是代码:

TempFileName = Regex.Replace(vehicle.FileUpload.FileName, "[^a-zA-Z0-9_]+", "_", RegexOptions.Compiled);
var directiveToUpload = Path.Combine(_hostingEnvironment.WebRootPath, "images\\UploadFile");

if (!System.IO.Directory.Exists(directiveToUpload))
{
    System.IO.Directory.CreateDirectory(directiveToUpload);
}

await SaveFileToServer(TempFileName);
Run Code Online (Sandbox Code Playgroud)

保存文件:

async Task SaveFileToServer(string FileName)
{

    if (vehicle.FileUpload.Length > 0)
    {
        using (var stream = new FileStream(Path.Combine(directiveToUpload, FileName), FileMode.Create))
        {
            await vehicle.FileUpload.CopyToAsync(stream);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

由于文件已上传,但它不会在 mac 上创建子文件夹。images\UploadFile这不起作用。

图片上传

c# asp.net asp.net-mvc asp.net-core

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