我遇到过一种情况,我从 Angular 6 应用程序调用 Spring Boot 应用程序。当我以与在不同端口上运行的应用程序的角度调用 HTTP post 方法时,它会引发异常。
从源“ http://localhost: 4200 ”访问位于“http://localhost:8080/api”的XMLHttpRequest已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:它没有 HTTP好的状态。
我的 Angular 应用程序在“ http://localhost:4200 ”上运行,端口号:4200 我的 Spring Boot 应用程序在“ http://localhost:8080/api ”上运行:端口号:8080。
没有直接的答案可以解决这个问题。有一些技巧可以禁用 Chrome 中的安全性,使用 NGINX 可以解决此问题。
我需要通过 共享桌面屏幕Angular 6。我已经搜索了合适的包来实现此功能,但找不到。
实际上我发现了很多包,比如RecordRTC、Aperture、screen-capture-recorder等等。其中一些不兼容,一些文档记录不足,并且代码智能感知不可用。
请告诉我可以与Angular 6. 我正在工作的平台是Windows
首先运行代码片段,然后阅读说明...它将为您提供结构
我想在第二个中录制、播放和保存视频video element。我面临的问题是:流正在第一个运行video-element但无法录制和保存视频
.video {
border: 1px solid gray;
box-shadow: 3px 4px lightgray;
}Run Code Online (Sandbox Code Playgroud)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div style="text-align:center">
<h1>Welcome to WebRTC</h1>
<video class="video" #video autoplay controls></video>
<video class="video" style="width:360;" autoplay controls #recordedVideo></video>
<br>
<button class="btn btn-warning" (click)="startRecording()">Start</button>
<button class="btn btn-warning" (click)="stopRecording()">Stop</button>
<button class="btn btn-warning" (click)="playRecording()">Play</button>
</div>Run Code Online (Sandbox Code Playgroud)
我在这里所做的,在Luis Estevez代码中,我在方法中声明了该事件startRecording,因为当我尝试将流块推送到 blob 数组中时,它响应了一个错误:推送方法不存在,即使我在之后创建了一个对象数组我声明了一个数组。
startRecording(stream) {
let options = { mimeType: 'video/webm' }
this.recordedBlobs = []
console.log(this.recordedBlobs)
try {
this.mediaRecorder = new MediaRecorder(stream, …Run Code Online (Sandbox Code Playgroud) primeng p表可调整列大小的问题
<p-table [resizableColumns]="true" columnResizeMode="expand" [value]="data" sortMode="multiple" [style]="{width:'100%'}" [scrollable]="true" [scrollHeight]="height" [columns]="columnList" (onColResize)="onBusinessLogicTableColResize($event)">
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col *ngFor="let col of groupHeaderColSpan" [style.width]="col.width + 'px'">
</colgroup>
</ng-template>
<ng-template pTemplate="header" let-columns>
<tr class="text-center">
<th *ngFor="let col of columnList" [colSpan]="col.colSpan" [rowSpan]="col.rowSpan" pResizableColumn>
{{col?.header}}
</th>
</tr>
<tr class="text-center">
<ng-template ngFor let-col [ngForOf]="columnList">
<th *ngFor="let subheader of col?.subheaders" [colSpan]="subheader.colSpan" [rowSpan]="subheader.rowSpan">
{{subheader?.header}}
</th>
</ng-template>
</tr>
</ng-template>
<ng-template pTemplate="body" let-columnValue let-rowIndex="rowIndex" let-columns="columns">
<ng-template ngFor let-col [ngForOf]="columns">
<ng-template [ngIf]="col.hasOwnProperty('subheaders')" [ngIfElse]="showData">
<td class="ui-resizable-column" *ngFor="let sub of col.subheaders" class="text-center">
{{columnValue[sub.field]}} …Run Code Online (Sandbox Code Playgroud) 我正在 Angular 6 中使用 Renderer2 和 ViewContainerRef。\n我想将新组件动态渲染到由 Renderer2 渲染的div 。
\n\n基本上,这就是我希望它发生的方式。
\n\nconst el = this.renderer.createElement(\'div\');\nthis.viewContainerRef: ViewContainerRef = el;\nconst factory = this.factoryResolver.resolveComponentFactory(element.elementComponentType);\nconst componentRef = this.viewContainerRef.createComponent(factory);\nRun Code Online (Sandbox Code Playgroud)\n\n渲染后的 HTML 应该是这样的
\n\n<div> <--- This will be the viewContainerRef\n <app-component></app-component> <--- this is the dynamic Component that I want to render\n</div>\nRun Code Online (Sandbox Code Playgroud)\n\n\xe2\x80\x94 更新 \xe2\x80\x94
\n\n感谢麦克斯,已经找到了我祈祷的答案。
\n\n链接: https: //stackoverflow.com/a/44853707
\n\n事实证明\xe2\x80\x99不需要一个新的视图viewContainerRef来显示工厂。
\n\n模组,现在可以关闭它或参考我上面提到的链接。
\n这个问题花了我一整天的时间,我不明白发生了什么
我可以看到我的 Service Worker 已注册,但是“有时”当我在开发人员工具中单击离线时,我的域的 ServiceWorker 就会消失!
但这是主要问题,当我重新加载应用程序时,我看到以下行为。
您可以看到 ngsw.json 加载了两次,main.js 加载了 3 次!main.d3ae2084xxxx && main.bbe5073dxxxx && 然后再次 main.d3ae2084xxxx !
如果我检查两个 ngsw.json 请求的响应,您可以看到两者都显示 main.d3ae2084xxxx 作为 main.js 的正确版本,但它仍然加载 main.bbe5073dxxxx...
第一个 ngsw.json 请求
第二个 ngsw.json 请求
更令人沮丧的是,实际加载的版本是以前的main.bbe5073dxxxx...!!!!
如果有人有任何想法如何发生这种情况,请告诉我。
更新...所以发现了这个优秀的小端点
https://you-app-url/ngsw/state
Run Code Online (Sandbox Code Playgroud)
这将为您提供有关 Service Worker 的大量调试信息。
就我而言,这个
驱动程序状态:EXISTING_CLIENTS_ONLY(由于初始化失败而降级:哈希不匹配(cacheBustedFetchFromNetwork): https://dev-xxxx.net/main.eb8468bb3ed28f02d7c2.js:预期b5601102b721e0cf777691d327dc965d40d1c96e,得到83c18fdb4a594 2c964a31c119a57e0b8e16fe46e(缓存清除后)
因此,在我的情况下,这似乎是某种 CDN 问题,当我确定时将更新答案。
我正在学习 Angular 6 的 MEAN 堆栈应用程序。在这里,我想在添加新的客户端/汽车/司机/预订或更新新的客户端/汽车/司机/预订后刷新组件。但是添加新值后,显示所有值的组件不会更新或刷新(当时无法看到当前值),但是当我在组件之间路由然后返回到它更新并显示的同一组件时所有的值。
我希望当从对话框表单添加或更新值时,它会在那时显示。
这是add client component
export class AddClientComponent implements OnInit {
clientForm: FormGroup;
constructor(private fb: FormBuilder,
private clientService: ClientService,
private toastr: ToastrService,
private router: Router,
public dialogRef: MatDialogRef < AddClientComponent > ) {
this.clientForm = this.fb.group({
'clientname': new FormControl(""),
'clientphoneno': new FormControl(""),
'clientemail': new FormControl(""),
'clientaddress': new FormControl("")
});
}
ngOnInit() {
this.router.navigate(['/admin/clients']);
}
saveClient(formdata: any) {
let theForm = this.clientForm.value;
this.clientService.addClient(theForm).subscribe(data => {
if (data.success === false) {
this.toastr.error(data.message);
} else {
this.toastr.success(data.message); …Run Code Online (Sandbox Code Playgroud)我有一个input HTML File归档
<input type="file" class="custom-file-input" id="question-file-upload" formControlName="image" (change)="handleFileSelect($event)">
Run Code Online (Sandbox Code Playgroud)
我想对handleFileSelect功能进行单元测试。但我不知道如何触发onChange输入的方法。以下是spec我写的,但出现错误imageInputNE.onchange is not a function
fit('should keep track of image counter when an image is loaded', () => {
let newPracticeQuestionComponent = component;
expect(newPracticeQuestionComponent.currentImageAttachmentCount).toBe(0);
let imageInputDE = fixture.debugElement.query(By.css("#question-file-upload"));
expect(imageInputDE).toBeTruthy();
spyOn(newPracticeQuestionComponent,'handleFileSelect');
let imageInputNE:HTMLElement = imageInputDE.nativeElement as HTMLElement;
imageInputNE.onchange(new Event("some event"));
expect(newPracticeQuestionComponent.handleFileSelect).toHaveBeenCalled();
});
Run Code Online (Sandbox Code Playgroud) 我们有一个 Angular 6 项目,其中在 node_modules 文件夹中包含大约 660 MB 的包。自项目启动以来,在构建项目时,我们将删除整个 node_modules 文件夹,然后执行 npm install 来重新下载并安装package.json.
然而,构建时间已增加至 15 - 20 分钟。如果我们注释掉删除该文件夹的命令,则构建时间将在 3 - 4 分钟之间。始终拥有已定义软件包的全新下载会给我们带来什么好处?
我在 Angular 6 项目中使用 simplebar 库(https://github.com/Grsmto/simplebar),当我在 html 标签中添加简单栏时,它显示了一个水平和垂直滚动条,所以我只想显示垂直滚动条。
我尝试使用以下 CSS 属性隐藏水平滚动条:
overflow-x: hidden
Run Code Online (Sandbox Code Playgroud)
也具有以下属性:
width:100%" and "position:abolute" or "position:relative"
<div data-simplebar style="overflow-x: hidden">
<div *ngFor="let example of examples;">
<div>{{example.title}}</div>
<p>{{example.text}}</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望只显示水平滚动条,但它似乎不起作用,我不知道是否缺少某些内容或某些 CSS 属性,或者 Angular 是否导致了此问题。
angular6 ×10
angular ×6
typescript ×3
html ×2
javascript ×2
angular-pwa ×1
angular-test ×1
cors ×1
cross-domain ×1
css ×1
express ×1
html-table ×1
jenkins ×1
node-modules ×1
node.js ×1
primeng ×1
spring-boot ×1
webrtc ×1