小编Voj*_*vic的帖子

尝试激活时无法解析类型服务

我有一个Repository.cs包含接口的文件及其实现如下:

public interface IRepository

{
    IEnumerable<City> Cities { get; }
    void AddCity(City newCity);
}

public class MemoryRepository : IRepository
{
    private List<City> cities = new List<City> {
        new City { Name = "London", Country = "UK", Population = 8539000},
        new City { Name = "New York", Country = "USA", Population = 8406000 },
        new City { Name = "San Jose", Country = "USA", Population = 998537 },
        new City { Name = "Paris", Country = "France", Population = …
Run Code Online (Sandbox Code Playgroud)

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

13
推荐指数
4
解决办法
4万
查看次数

Angular 4 - Http到HttpClient - 属性'someproperty'在Object类型上不存在

我正在尝试将现有应用程序从使用更改Http为使用HttpClient,但是我有一个错误.

因此,在我的服务中,您现在可以看到新代码与已注释掉的旧代码:

constructor(
        // private http: Http
        private http: HttpClient
    ) { }

    getSidebar() {
        // return this.http.get('http://localhost:3000/sidebar/edit-sidebar')
        //     .map(res => res.json());
        return this.http.get('http://localhost:3000/sidebar/edit-sidebar');
    }
Run Code Online (Sandbox Code Playgroud)

在我,page.component.ts我有这个

this.sidebarService.getSidebar().subscribe(sidebar => {
                        this.sidebar = sidebar.content; // this does not work now
                    });
Run Code Online (Sandbox Code Playgroud)

但是对于我评论过的行,我现在得到了这个错误:

Property 'content'
 does not exist on type 'Object'.
Run Code Online (Sandbox Code Playgroud)

但是,如果我console.log(sidebar)得到以下内容:

{_id: "59dde326c7590a27a033fdec", content: "<h1>sidebar here</h1>"}
Run Code Online (Sandbox Code Playgroud)

那么问题是什么?

再一次,Http有效,但HttpClient没有.

typescript angular

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

每2个div换一个新的div

说我有这个:

<div class="somediv"></div>
<div class="somediv"></div>
<div class="somediv"></div>
<div class="somediv"></div>
<div class="somediv"></div>
<div class="somediv"></div>
Run Code Online (Sandbox Code Playgroud)

如何将每2个div包装到一个带有“ newdiv”类的新div中?

html jquery

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

基于条件的显示组件

我有这个领域 app.component.ts

front: boolean = true;
Run Code Online (Sandbox Code Playgroud)

我正在显示这个组件模板 app.component.html

<app-navbar></app-navbar>
Run Code Online (Sandbox Code Playgroud)

那行得通,但我想根据 的值显示该组件(或不显示)front,所以我尝试了这样的操作,但它不起作用:

<*ngIf="front" app-navbar></app-navbar>
Run Code Online (Sandbox Code Playgroud)

如何实现这一目标?

angular

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

角度4*ng如果没有按预期工作

我显示了一堆li,我从Web服务中获得的链接,这些链接中有titleslug财产.

问题是,我不想显示li,如果slug属性home,但是*ngIf指令不是让我的代码中的差异:

<ng-container *ngFor="let page of pages">
                <li *ngIf="page.slug!==home">
                    <a routerLink="{{ page.slug }}">{{ page.title }}</a>
                </li>
            </ng-container>
Run Code Online (Sandbox Code Playgroud)

我得到的所有页面,包括一个用slughome.我怎么能避免这种情况?

angular

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

标签 统计

angular ×3

asp.net-core ×1

asp.net-core-mvc ×1

c# ×1

html ×1

jquery ×1

typescript ×1