我刚刚从Angular 2 beta16升级到beta17,后者又需要rxjs 5.0.0-beta.6.(更改日志:https://github.com/angular/angular/blob/master/CHANGELOG.md#200-beta17-2016-04-28)在beta16中,所有关于Observable/map功能的都很好.升级后出现以下错误,当typescript尝试转换时出现:
- 类型'Observable'上不存在属性'map'(我在地图中使用了带有observable的地图)
- c:/path/node_modules/rxjs/add/operator/map.d.ts(216):error TS2435:Ambient模块不能嵌套在其他模块或名称空间中.
- c:/path/node_modules/rxjs/add/operator/map.d.ts(2,16):错误TS2436:环境模块声明无法指定相对模块名称.
我已经看到了这个问题/答案,但它没有解决问题: Angular2 beta.12和RxJs 5 beta.3的可观察错误
我的appBoot.ts看起来像这样(我已经引用了rxjs/map):
///<reference path="./../node_modules/angular2/typings/browser.d.ts"/>
import {bootstrap} from "angular2/platform/browser";
import {ROUTER_PROVIDERS} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
[stuff]
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/toPromise';
import {enableProdMode} from 'angular2/core';
import { Title } from 'angular2/platform/browser';
//enableProdMode();
bootstrap(AppDesktopComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
Title
]);
Run Code Online (Sandbox Code Playgroud)
有人知道发生了什么事吗?
我在Visual Studio 2015(带有resharper)的上下文中工作,并且正在引用node.js的typescript定义文件.我有3个其他VS项目使用node.d.ts没有问题.然而,在这个新项目中,我现在有146个错误说同样的事情:
"Typescript Feature 1.5.当前语言级别为1.4".
对于我的生活,我无法告诉Visual Studio(或Resharper?)使用最新的打字稿语言版本.
我试过了: 工具>选项>打字稿>项目>常规> ECMAScript6(已选中)不起作用
另外:npm install -g typescript不起作用
我怎么告诉VS使用Typescript 1.5.3(node.d.td要求的)?
我正在使用VS 2015,我有一个项目,习惯性地崩溃/重启大约10分钟.我的所有项目都没有发生,它似乎只是一个违规的项目.分析导致崩溃的原因的最佳方法是什么?
我正在将 WebApi 从 .net5 迁移到 .net6。一切进展顺利,但遇到了如何在启动过程中配置 Kestrel 的问题。以下代码来自 Program.cs 文件的 Main 方法:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddVariousStuff();
builder.Host
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions =>
{
serverOptions.Limits.MaxConcurrentConnections = 100;
serverOptions.Limits.MaxConcurrentUpgradedConnections = 100;
serverOptions.Limits.MaxRequestBodySize = 52428800;
});
});
var app = builder.Build();
app.UseStuffEtc();
app.Run();
Run Code Online (Sandbox Code Playgroud)
应用程序启动崩溃并出现以下异常:
System.NotSupportedException:WebApplicationBuilder.Host 不支持ConfigureWebHost()。请改用 WebApplicationBuilder.Build() 返回的 WebApplication。
如果我删除与ConfigureWebHostDefaults相关的任何内容,那么应用程序启动就没有问题。我无法弄清楚如何使用新的 .net6 Kestrel 服务器启动配置。
c# kestrel-http-server asp.net-core asp.net-core-6.0 .net-6.0
我已将不断增长的ng2应用程序升级到RC5,并将所有组件/管道放入一个胖主模块中.为了对抗臃肿,我试图将我的应用程序分成单独的模块(同时着眼于最终进行延迟加载).
这是我创建的子模块,其中包含一些通用组件:
我-shared.module.ts
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { provideForms, disableDeprecatedForms } from"@angular/forms";
import { TabBarWidgetComponent } from "./tabBarWidget/tabbar-widget.component";
import { MyDatepickerComponent } from "./mykDatePicker/my-datepicker.component";
import { CalendarSelectorComponent } from "./calendarSelector/calendar-selector.component";
import { AccordionTabComponent } from "./accordionTab/accordion-tab.component";
@NgModule({
imports: [
BrowserModule,
FormsModule
],
declarations: [
TabBarWidgetComponent,
MyDatepickerComponent,
CalendarSelectorComponent,
AccordionTabComponent
],
providers: [
provideForms(),
disableDeprecatedForms()
]
})
export class MySharedModule { }Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.现在我想在主app.module.ts中引用这个MySharedModule,我正在做这样的事情:
import { NgModule } …Run Code Online (Sandbox Code Playgroud)我基本上想要创建一个自定义对话框组件,我可以在我的Angular2应用程序中的任何位置使用它,无论应用程序树中的using组件位于何处.为简单起见,我们称之为SayHello组件.
所以,假设我想要SomeComponent.level3.component来调用SayHello.component中的对话框.
在Angular 1.x中,我会将RootScope注入控制器并以此方式点亮对话框.现在,我了解(或多或少)对于Angular2,你可以在组件树上冒泡事件(使用事件发射器),但是从树上的SomeComponent.level3.component向下到SayHello一直冒泡一个事件似乎很乏味. .零件.
所以我想我会创建一个SayHello服务,我会在任何想要点亮对话框的地方注入.这是我制定的代码草图.
myApp.component.ts
import {SayHelloComponent} from "<<folder>>/sayHello.component";
import {BunchOfComponents} from "<<folder>>/bunchOfComponents";
@Component({
directives: [SayHelloComponent],
selector: "my-app",
templateUrl: `<bunch-of-components>Within this component exists
SomeComponent.level3.component </bunch-of-components>
<say-hello showdialog="{{showDialog}}" message="{{message}}">
</say-hello>`
})
export class myAppComponent {
showDialog = false;
message = "";
constructor(private sayHelloService: SayHelloService) {
this.showDialog = sayHelloService.showDialog;
this.message = sayHelloService.message;
}
}
Run Code Online (Sandbox Code Playgroud)
SayHelloService.ts
import {Injectable} from 'angular2/core';
@Injectable()
export class SayHelloService {
public showDialog: boolean = false;
public message: string ="";
constructor() { …Run Code Online (Sandbox Code Playgroud) 我有一个Asp.net 5 Web应用程序,在开发中运行良好(从Visual Studio或VS代码我可以启动没问题).然而,在成功发布应用程序,试图与启动网站时,"web.cmd"出现以下错误,并防止网站从不断加载:
Application startup exception: System.IO.FileNotFoundException: Could not load file or assembly 'my-ng2-website' or one of its dependencies. The system cannot find the file specified.
File name: 'my-ng2-website' ---> System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath)
at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext)
at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName)
at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName)
at Microsoft.Dnx.Host.DefaultLoadContext.LoadAssembly(AssemblyName assemblyName)
at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func`2 factory)
at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadAssemblyImpl(AssemblyName assemblyName)
at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs …Run Code Online (Sandbox Code Playgroud)应用程序在Chrome和IE(11)中运行良好,但在Firefox(42.0)或Safari(5.1.7)中无效.
FIREFOX:
改变对象的[[Prototype]]会导致代码运行得非常慢; 而是使用Object.create es6-shim.js创建具有正确的初始[[Prototype]]值的对象:1338:11
Angular 2正在开发模式下运行.调用enableProdMode()以启用生产模式.angular2.dev.js:351:5
EXCEPTION:错误:期望int32作为第二个参数angular2.dev.js:23524
BrowserDomAdapter</BrowserDomAdapter.prototype.logError() angular2.dev.js:23514
BrowserDomAdapter</BrowserDomAdapter.prototype.logGroup() angular2.dev.js:23525
ExceptionHandler</ExceptionHandler.prototype.call() angular2.dev.js:1145
PlatformRef_</PlatformRef_.prototype._initApp/</<() angular2.dev.js:14801
NgZone</NgZone.prototype._notifyOnError() angular2.dev.js:5796
NgZone</NgZone.prototype._createInnerZone/errorHandling<.onError() angular2.dev.js:5700
run() angular2-polyfills.js:141
map@http://localhost:53861/lib/es6-shim/es6-shim.js:1113:14
TemplateParseVisitor</TemplateParseVisitor.prototype._createDirectiveAsts@http://localhost:53861/lib/anguar2/angular2.dev.js:24301:27
TemplateParseVisitor</TemplateParseVisitor.prototype.visitElement@http://localhost:53861/lib/anguar2/angular2.dev.js:24154:24
HtmlElementAst</HtmlElementAst.prototype.visit@http://localhost:53861/lib/anguar2/angular2.dev.js:20216:14
htmlVisitAll/<@http://localhost:53861/lib/anguar2/angular2.dev.js:20227:23
forEach@http://localhost:53861/lib/es6-shim/es6-shim.js:1107:14
htmlVisitAll@http://localhost:53861/lib/anguar2/angular2.dev.js:20226:5
TemplateParser</TemplateParser.prototype.parse@http://localhost:53861/lib/anguar2/angular2.dev.js:24038:20
TemplateCompiler</TemplateCompiler.prototype._compileComponentRuntime/done<@http://localhost:53861/lib/anguar2/angular2.dev.js:24669:32
run@http://localhost:53861/lib/anguar2/angular2-polyfills.js:138:14
NgZone</NgZone.prototype._createInnerZone/<.$run/<@[…]Run Code Online (Sandbox Code Playgroud)
SAFARI:
EXCEPTION: Error during instantiation of BrowserDetails! (Token Promise<ComponentRef> -> DynamicComponentLoader -> Compiler -> RuntimeCompiler -> ProtoViewFactory -> Renderer -> DomRenderer -> AnimationBuilder -> BrowserDetails).
angular2.dev.js:23514ORIGINAL EXCEPTION: TypeError: 'undefined' is not a function (evaluating 'window.requestAnimationFrame(callback)')Run Code Online (Sandbox Code Playgroud)
Potentially unhandled rejection [2] Error: EXCEPTION: Error during instantiation of …Run Code Online (Sandbox Code Playgroud)我有一个angular2应用程序在Chrome和Firefox中运行良好,但在Safari中我收到此错误:
TypeError el.createShadowRoot不是函数
在Edge中同样如此:
对象不支持BrowserDomAdapter.prototype.createShadowRoot中的属性或方法'createShadowRoot'(http:// localhost:5000/lib/angular2/bundles/angular2.dev.js:22893:7)
我缺少一些垫片或聚合物吗?
我正在使用 CQRS 方法重新设计一个 dotnet 后端 api。这个问题是关于如何在 Kubernetes 部署的上下文中处理 Query 端。
我正在考虑使用 MongoDb 作为查询数据库。该应用程序是 dotnet webapi 应用程序。那么最好的方法是什么:
创建一个 sidecar Pod,它将 dotnet 应用程序和 MongoDb 容器化到一个 Pod 中。根据需要进行缩放。
将 MongoDb 容器化到它自己的 pod 中,并在每个区域部署一个 MongoDb pod。然后让 dotnet 容器在其自己的区域内使用 MongoDb pod。按区域缩放 MongoDb。以及区域内和区域之间需要的 dotnet pod。
我还没有想到的其他一些方法
我正在重新设计 ASP.NET CORE 2.2 应用程序,以避免将服务定位器模式与静态类结合使用。双坏!
重新工具涉及创建和注入 Singleton 对象作为某些全局数据的存储库。这里的想法是为了避免在请求中反复使用的一些基本/全局数据访问我的 SQL 服务器。但是,此数据需要每小时更新一次(而不仅仅是在应用程序启动时更新)。因此,为了管理这种情况,我使用 SemaphoreSlim 来处理对数据对象的一次访问。
这是我正在做的事情的配对草图:
namespace MyApp.Global
{
public interface IMyGlobalDataService
{
Task<List<ImportantDataItem>> GetFilteredDataOfMyList(string prop1);
Task LoadMyImportantDataListAsync();
}
public class MyGlobalDataService: IMyGlobalDataService
{
private MyDbContext _myDbContext;
private readonly SemaphoreSlim myImportantDataLock = new SemaphoreSlim(1, 1);
private List<ImportantDataItem> myImportantDataList { get; set; }
public async Task<List<ImportantDataItem>> GetFilteredDataOfMyList(string prop1)
{
List<ImportantDataItem> list;
myImportantDataLock.WaitAsync();
try
{
list = myImportantDataList.Where(itm => itm.Prop1 == prop1).ToList();
}
finally
{
myImportantDataLock.Release();
}
return list;
}
public async Task LoadMyImportantDataListAsync()
{ …Run Code Online (Sandbox Code Playgroud)c# singleton dependency-injection semaphore asp.net-core-2.2
在下面的模型中,我使用信号作为组件的输入。有用。但我想知道这是否是信号的正确使用。看起来……很奇怪。
以下是维护“我的朋友”列表的服务:
import {
Injectable,
signal
} from '@angular/core';
export interface MyFriend {
name: string;
age: number;
}
@Injectable({
providedIn: 'root'
})
export class MyFriendsService {
myFriends = signal < MyFriend[] > ([{
name: 'Bob',
age: 34,
},
{
name: 'Julie',
age: 30,
},
{
name: 'Martin',
age: 25,
},
]);
}Run Code Online (Sandbox Code Playgroud)
以下是一个好友详细信息组件,显示特定好友的详细信息:
import {
Component,
Input,
computed,
signal
} from '@angular/core';
import {
MyFriend,
MyFriendsService
} from './my-friends.service';
@Component({
selector: 'app-friend-detail',
templateUrl: './friend-detail-component.html',
})
export class FriendDetailComponent {
@Input() …Run Code Online (Sandbox Code Playgroud)我刚刚从angular2.RC4升级到angular2.RC5.我现在正在
未捕获(承诺):TypeError:无法读取null的属性'create'
但我不知道在哪里找出如何解决它.以下是错误消息的屏幕截图:
我会发布代码,但是,我甚至不知道违规代码可能在哪里.有关如何诊断/修复此错误的任何想法?
angular ×7
asp.net-core ×2
c# ×2
typescript ×2
.net-6.0 ×1
cqrs ×1
dnx50 ×1
firefox ×1
kubernetes ×1
mongodb ×1
rxjs ×1
safari ×1
semaphore ×1
singleton ×1