我有一个ASP.NET Core 2.0/Angular模板应用程序.一切正常,直到我尝试发布.我收到以下错误:
in ./ClientApp/boot.browser.ts
Module parse failed: E:\rootfolder\ClientApp\boot.browser.ts Unexpected token (14:19)
You may need an appropriate loader to handle this file type.
| const oldRootElem = document.querySelector('app');
| const newRootElem = document.createElement('app');
| oldRootElem!.parentNode!.insertBefore(newRootElem, oldRootElem);
| modulePromise.then(appModule => appModule.destroy());
| });
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经完成了通常的谷歌搜索,没有运气.知道我应该在哪里看?这是一个使用VS 2017生成的角度模板的ASP.NET CORE 2.0应用程序.我在下面发布了package.json文件.我得到了相同的结果,我明确地调用了"donet publish"命令或者在VS 2017中按下发布按钮.
{
"name": "MyApp",
"private": true,
"version": "0.0.0",
"scripts": {
"test": "karma start ClientApp/test/karma.conf.js"
},
"dependencies": {
"@angular/animations": "^4.4.4",
"@angular/common": "^4.4.4",
"@angular/compiler": "^4.4.4",
"@angular/compiler-cli": "^4.4.4",
"@angular/core": "^4.4.4",
"@angular/forms": …Run Code Online (Sandbox Code Playgroud) 我有以下2种方法可以使用泛型在一种方法中压缩.我试过的东西无法编译.有人能让我知道如何做到这一点?我需要检查表AgeLengths的2个不同字段是否至少有一个值.Str_table与AgeLengths有一对多的关系.
public static bool HasMeanWeight(int id)
{
MyDataContext dc = new MyDataContext ();
return (from s in dc.Str_table
where s.SId == id
select s.AgeLengths
.Where(a => a.MeanWeight != null ).Any() == true
).FirstOrDefault();
}
public static bool HasNumbersData(int id)
{
MyDataContext dc = new MyDataContext ();
return (from s in dc.Str_table
where s.sId == id
select s.AgeLengths
.Where(a => a.Numbers != null).Any() == true
).FirstOrDefault();
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢B.
我有一个列表int?,可以有3个不同的值:null,1和2.我想知道哪些在我的列表中出现最多.为了按价值对它们进行分组,我尝试使用:
MyCollection.ToLookup(r => r)
Run Code Online (Sandbox Code Playgroud)
如何获得最多出现的值?
我正在尝试从表中检索一些信息,如下所示:
//Fish table: fishid(int32), SpeciesName(nvarchar(50)),age(int?), weight(int?)
(from f in Fish
where f.SpeciesName=="COD" || f.SpeciesName=="Salmon"
select f
).GroupBy(g=>g.SpeciesName)
.Select(s= > new
{
Species=s.Key,
Age= (from age_count in Fish where age_count.SpeciesName== s.key && age_count.age!=null select age_count).Count(),
Weight= (from Weight_count in Fish where Weight_count.SpeciesName== s.key && Weight_count.Weight!=null select weight_count).Count()
};
Run Code Online (Sandbox Code Playgroud)
现在,虽然这是有效的,但我认为必须有更好的方法.有人可以建议更好的代码吗?
谢谢
我有角度JWT令牌的问题,它可以在Postman的api上运行,但不能从角度调用中运行.请求详情如下:
我复制了响应中显示的令牌,并通过Postman生成请求.
知道为什么这个令牌在从角度服务发送时可能无效?
邮差结果如下:
这是生成令牌角边>的代码
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor} from '@angular/common/http';
//import { AuthService } from './auth/auth.service';
import { Observable } from 'rxjs/Observable';
import { Http } from "@angular/http/http";
import { AuthService } from "./auth.service";
import { HttpClient } from "@angular/common/http";
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
constructor(public auth: AuthService) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({
setHeaders: {
Authorization: `Bearer ${this.auth.getToken()}`
}
});
return next.handle(request);
} …Run Code Online (Sandbox Code Playgroud)