我想将反应式表单数据存储到本地存储并将该数据访问到另一个页面。
<form [formGroup]="testform" >
firstname:
<input type="text" formControlName="fname"><br>
lastname:
<input type="text" formControlName="lname">
<button type="submit" (click)="Submit(testform)">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
我希望有人知道这个问题。谢谢你。
我使用软件包通过 Angular 7 应用程序连接到 Xero oauth 服务器“ https://login.xero.com/identity/connect/authorize ” angular-oauth2-oidc。
在我的 authConfig 我有以下属性
export const authConfig: AuthConfig = {
issuer: 'https://login.xero.com/identity/connect/authorize',
redirectUri: 'http://127.0.0.1:2114/xerocallback',
clientId: 'XXXXXXXXXX647C2ABBAXXXXXXXXXX',
scope: 'openid profile email offline_access',
responseType: 'code',
};
Run Code Online (Sandbox Code Playgroud)
但是,一旦我初始化 oauth 服务
import { OAuthService } from 'angular-oauth2-oidc';
this.oauthService.configure(authConfig);
Run Code Online (Sandbox Code Playgroud)
我收到以下 CORS 错误
Access to XMLHttpRequest at 'https://login.xero.com/identity/connect/authorize/.well-known/openid-configuration' from origin 'http://localhost:2114' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Run Code Online (Sandbox Code Playgroud)
任何我做错了什么的想法,任何建议都会受到欢迎
我正在实施角度谷歌地图,我从用户那里获取接送和目的地位置,并<agm-direction>在角度谷歌地图中显示方向。我已经在地图上显示了起点和目的地的标记,但在实施之后<agm-direction>它开始显示默认标记“A”和“B”。我想从地图中删除这些标记,或者将默认图标从“A”和“B”更改为其他图标。
<agm-map id="map" [latitude]='lat' [longitude]='lng' (mapReady)="addMarker()" [zoom]='zoom'>
<agm-marker [iconUrl]="curicon" [latitude]="lat" [longitude]="lng"></agm-marker>
<agm-marker [iconUrl]="desticon" [latitude]="latitude" [longitude]="longitude"></agm-marker>
<agm-direction [origin]="origin" [destination]="destination" >
</agm-direction>
</agm-map>
ts code :
public origin: {lat :30.7224576,lng:76.6984192};
public destination: {lat:30.7134158,lng:76.71059969999999};
public curicon="http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
public desticon="http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png";
Run Code Online (Sandbox Code Playgroud) 我向服务器发出请求并获得 JSON 结果:
{"result" => "HTML code"}
Run Code Online (Sandbox Code Playgroud)
如何解析 HTML 代码并从此响应中获取表格?
我试图将此代码放在页面上的隐藏块中:
<div #content>HTML code here from response</div>
Run Code Online (Sandbox Code Playgroud)
接下来是什么?如何解析?
我正在尝试在 Angular 中上传图片或视频。我想显示它的预览。我在预览图像时没有问题,我的问题是如何预览视频?请看这个stackblitz链接:
代码
onSelectFile(event) {
if (event.target.files && event.target.files[0]) {
var reader = new FileReader();
reader.readAsDataURL(event.target.files[0]);
reader.onload = (event) => {
this.url = event.target.result;
}
}
}
Run Code Online (Sandbox Code Playgroud) import {
Observable,
BehaviorSubject
} from 'rxjs';
import {
finalize,
share
} from 'rxjs/operators'
export class someComponent() {
public count$ = new BehaviorSubject < any > (0);
public constructor() {
this.shareResponse()
.pipe(
finalize(() => {
console.log('finalize called');
}))
.subscribe((event: any) => {
// Do something
});
}
public shareResponse(): Observable < any > {
return this.count$.pipe(share());
}
public countChanged(event) {
this.count$.next(event);
}
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<some-tag(countChanged) = (countChanged($event)) > < /some-tag>
Run Code Online (Sandbox Code Playgroud) 我有一个 Angular 应用程序,它应该能够根据用户创建新路线。比方说,用户johndoe的“寄存器,然后应用程序应该创建一个路线:domain/johndoe。
当然,/johndoe路线应该提供一些关于特定用户的信息(如姓名、图像等)。
我使用 Google Cloud Hosting 和 Firestore 作为后端解决方案,到目前为止我的进展是将 注入Router到我的AppComponent构造函数中,然后unshift在router.config. 那种工作,但我必须将所有新路由('用户')存储到我的数据库中的一个单独的文件中,然后每次有人导航到一个私有的死记硬背(例如domain/johndoe)时查询数据库。
是否有一个美观且易于维护的解决方案,它考虑了我的后端配置?
现在我有一个以 Angular 7 作为客户端的 .Net Core 应用程序
我在 Azure 上部署了 API 和客户端,但是我一直在思考如何让客户端在到达 .Net Core 端点的 azure 上工作。在我的登录帖子请求中,我收到了 404,但它适用于我的本地构建......我不确定我做错了什么?
Request Method: POST
Status Code: 404 Not Found
Referrer Policy: no-referrer-when-downgrade
Run Code Online (Sandbox Code Playgroud) 我CKEditor 5在我的angular 7应用程序中使用。ClassicEditor默认情况下显示Insert Media工具栏上的按钮,如下图突出显示。
在网上研究时,我发现我们可以使用下面的removePlugins选项禁用特定选项editorConfig。
editor.component.ts
editorConfig = {
removePlugins: ['Image'],
placeholder: 'Type the content here!'
};
Run Code Online (Sandbox Code Playgroud)
上面的代码不是删除Insert Media选项,而是一个不同的选项Insert Image。但它不起作用。即使在使用上面的代码之后,我仍然可以在我的 CK 编辑器中看到图像插入选项。
我也无法在网上找到我需要在removePlugins禁用Insert Media选项中提供的内容,如果至少可行的话。任何帮助将不胜感激。
提前致谢
在 Angular 7 应用程序中,当我执行 ng serve 命令时,它会抛出“JavaScript heap out of memory”错误。
从不同的 SO 答案中,我可以理解问题是由于对 Node.js 的内存分配不足。正如他们的回答中提到的,通过执行以下命令,我可以编译/构建 angular 应用程序。
node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng serve
Run Code Online (Sandbox Code Playgroud)
但是我需要在 package.json 或一些配置文件中编写这个内存分配代码,这样我就不需要每次都执行整个命令。同样期待,代码逻辑应该适用于所有环境,并且在更高的环境中构建期间不应产生任何问题。
有人可以帮我解决这个问题。下面是我的 package.json 代码。
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.config.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Run Code Online (Sandbox Code Playgroud) angular7 ×10
angular ×6
angular6 ×2
angular8 ×2
javascript ×2
.net-core ×1
agm-map ×1
asp.net-core ×1
azure ×1
ckeditor ×1
ckeditor5 ×1
dynamic ×1
events ×1
filereader ×1
google-maps ×1
html ×1
node.js ×1
oauth-2.0 ×1
routes ×1
rxjs ×1
typescript ×1
xero-api ×1