小编Ste*_*zor的帖子

从Angular 2中的Web API获取数据

感谢Angular 2页面上的"英雄之旅"教程,我设法创建了一个简单的Angular 2应用程序.然后使用Enitity Framework我决定创建一个数据库.并从中填充英雄列表(不是从文件中).我创建了Web Api Controller并添加了简单的get方法.然后在hero.service.ts我调用此方法以获取英雄列表.当我在我的应用程序午餐时,它会显示英雄列表,但没有任何值(名称和ID为空白).当我在浏览器中调试我的应用程序时,我可以看到this.heroes对象heroes.component.ts包含正确的数据.那么发生了什么?为什么不nameid展示?

hero.service.ts:

import {Injectable} from 'angular2/core';
import {HEROES} from './mock-heroes';
import {Hero} from './hero';
import {Http, Response} from 'angular2/http';
import 'rxjs/Rx';
import {Observable}     from 'rxjs/Observable';

@Injectable()
export class HeroService {

    public values: any;

    constructor(public _http: Http) { }

    private _heroesUrl = 'http://localhost:61553/api/values'; // URL to web api

    getHeroes() {
        return this._http.get(this._heroesUrl)
            .map(res => <Hero[]>res.json())
            .catch(this.handleError);
    }
    private handleError(error: Response) {
        console.error(error);
        return Observable.throw(error.json().error …
Run Code Online (Sandbox Code Playgroud)

json entity-framework asp.net-web-api angular

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

在调试中时,ApplicationInsights TelemetryClient初始化速度很慢

我的Microsoft.ApplicationInsights物体有问题。每次代码第一次碰到这些对象中的一个,初始化时间就非常长(有时甚至是40秒左右)。

范例1:

首次初始化TelemetryClient

范例2:

禁用Telemtry

如此长的首次加载的原因是什么?我怎样才能解决这个问题?

c# azure-application-insights

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