小编Mag*_*röm的帖子

如何解决请求与 .Net Core Web Api 中的多个端点匹配的问题

我注意到有很多关于这个主题的类似问题。

调用以下任何方法时出现此错误。

Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException:请求匹配多个终结点。

但是,我无法弄清楚解决问题的最佳做法是什么。到目前为止,我还没有设置任何特定的路由中间件。

// api/menus/{menuId}/menuitems
[HttpGet("{menuId}/menuitems")]
public IActionResult GetAllMenuItemsByMenuId(int menuId)
{            
    ....
}

// api/menus/{menuId}/menuitems?userId={userId}
[HttpGet("{menuId}/menuitems")]
public IActionResult GetMenuItemsByMenuAndUser(int menuId, int userId)
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

c# .net-core asp.net-core-webapi asp.net-core-routing

37
推荐指数
3
解决办法
6万
查看次数

如何将响应从http.get映射到Angular 2中的类型化对象的新实例

我试图了解如何使用Angular 2中的http.get和Observables将服务调用的结果映射到对象.

看看这个Plunk

在方法getPersonWithGetProperty中,我期望返回一个类型为PersonWithGetProperty的Observable.然而!我无法访问属性fullName.我想我必须创建PersonWithGetProperty类的新实例,并使用类构造函数将响应映射到这个新对象.但是你如何在方法getPersonWithGetProperty中做到这一点?

import {Injectable} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Rx';

export class PersonWithGetProperty {
  constructor(public firstName: string, public lastName: string){}

  get fullName(): string {
    return this.firstName + ' ' + this.lastName;
  }
}

@Injectable()
export class PersonService {
    constructor(private http: Http) {
    }

    getPersonWithGetProperty(): Observable<PersonWithGetProperty> {
        return this.http.get('data/person.json')
         .map((response: Response) => <PersonWithGetProperty>(response.json()));
    }
}
Run Code Online (Sandbox Code Playgroud)

http-get observable rxjs typescript angular

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

如何在Angular 2中使用FullCalendar

我是Angular 2的新手,正试图掌握如何将Angular 2与现有的Javascript UI Framework库集成.

现在我正在尝试使用jQuery插件http://fullcalendar.io 或者实际上我想使用名为Scheduler的高级插件.

但是我在Plunker中创建了一个简单的例子......

随意使用它并启发我如何使其显示以及如何响应点击特定事件.

https://plnkr.co/edit/eMK6Iy

...组件FullCalendarComponent当然需要修改.问题是我不知道怎么做.

import {Component} from 'angular2/core';

@Component({
    selector: 'full-calendar',
    template: '<p>Here I would like to see a calendar</p>'
})

export class FullCalendarComponent { }
Run Code Online (Sandbox Code Playgroud)

fullcalendar angular

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

Angular2 QuickStart拒绝为发布候选版本构建

当候选版本发布时,我现在正在尝试浏览Angular2的快速入门。但是,打字稿编译器会抛出很多我无法弄清的错误。

https://angular.io/guide/quickstart

首先有很多这样的话。node_modules/@angular/core/src/application_ref.d.ts(39,88):错误TS2304:找不到名称“ Promise”。node_modules/@angular/core/src/application_ref.d.ts(99,42):错误TS2304:找不到名称“ Promise”。

然后这个... npm ERR!Windows_NT 6.1.7601 npm错误!argv“ C:\ Program Files(x86)\ nodejs \\ node.exe”“ C:\ Program Files(x86)\ nodejs \ node_modules \ npm \ bin \ npm-cli.js”“运行”“ tsc” npm ERR !节点v0.12.2 npm ERR!npm v2.7.4 npm错误!代码ELIFECYCLE npm ERR!angular2-quickstart@1.0.0 tsc:tsc npm错误!退出状态2 npm ERR!npm ERR!在angular2-quickstart@1.0.0 tsc脚本'tsc'处失败。npm ERR!angular2-quickstart软件包npm ERR很可能是一个问题!不与npm本身。npm ERR!告诉作者这在您的系统上失败:npm ERR!tsc npm错误!您可以通过以下方式获取其信息:npm ERR!npm所有者ls angular2-quickstart npm错误!上面可能还有其他日志记录输出。

npm ERR!请在支持请求中包含以下文件:npm ERR!C:\ Development \ Angular2RCQuickstart \ npm-debug.log

有人知道怎么了吗?

typescript angular

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

使用 Typescript 在 Angular 2 中获取属性

我正在尝试使该属性fullName显示名字和姓氏。如何使 get 属性起作用?

看到这个Plunk

import { Component } from '@angular/core';

export class Person {
  id: number;
  firstName: string;
  lastName: string;
  get fullName(): string {
    return this.firstName + ' ' + this.lastName;
  }
}

@Component({
  selector: 'my-app',
  template:`
    <h1>{{title}}</h1>
    <p>My first name is {{person.firstName}}</p>
    <p>My last name is {{person.lastName}}</p>
    <h2>My full name is {{person.fullName}}!</h2>`
})
export class AppComponent {
  title = 'Get property issue';
  person: Person = {
    id: 1,
    firstName: 'This',
    lastName: 'That'
  };
}
Run Code Online (Sandbox Code Playgroud)

编辑 …

typescript angular

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

Angular 2 - 如何更改RxJS Observable的间隔

我正在使用rxJS Observable Interval刷新正在获取的数据.我无法弄清楚改变间隔设置的方法.我已经看到有关使用rxJS提供的Subject类的一些内容,但我无法让它工作.

我在这个插件中提供了一个简化的例子

在AppComponent中我有这个方法.

getTime() {
        this.timeService.getTime(this.refreshInterval)
          .subscribe(t => {
            this.currentTime = t;
            console.log('Refresh interval is: ' + this.refreshInterval);
          }
        );
}
Run Code Online (Sandbox Code Playgroud)

在服务组件中,我目前有这个代码.

getTime(refreshInterval: number) {
  return Observable.interval(refreshInterval)
        .startWith(0)
        .map((res: any) => this.getDate())
        .catch(this.handleError)
}
Run Code Online (Sandbox Code Playgroud)

有人可能会给我一个工作的例子,这将是伟大的!

observable rxjs rxjs5 angular

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