我正在尝试使用 Angular 5 连接到 Google Calendar API,以便我可以在我正在构建的 Web 应用程序上显示即将发生的事件。我是 Angular 的新手,我正在寻找一种将 API 集成到我的应用程序中的方法。我搜索了很多,但我没有找到一种方法来做到这一点。
我正在尝试构建一个用于部署到 IIS 的 Angular 5 项目。
当我运行以下命令时:
ng build --prod
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
./node-modules/bootstrap/dist/css/bootstrap.min.css 中的错误。
模块构建失败:BrowserslistError:未知的浏览器专业。
我阅读了有关此错误的信息,并看到建议的解决方案是将 Angular CLI 升级到 1.7.0 或更高版本。我的 CLI 版本是 1.7.3,Bootstrap 版本是 4.0.0。
如何修复此错误以便我可以构建我的解决方案?
我尝试使用电子打包器将我的电子项目构建到窗口应用程序,但出现此错误。
无法从“/var/www/windowapp/electron-angular-project/node_modules/@angular-devkit/core/node_modules/chokidar”中找到模块“fsevents”
This normally means that either you have deleted this package already somehow (check your ignore settings if using electron-packager). Or your module installation failed.
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何解决它以及发生了什么?
在具有角度材料 5.2.5 的 Angular 5 应用程序中,使用此代码时,默认选中的单选按钮正在工作,但控制台中出现错误
代码 :
<mat-radio-group [(ngModel)]="collection">
<mat-radio-button class="collectionRadioButton"
*ngFor="let coll of collections"
[value]="coll.endPoint"
[checked]="coll.isDefault"
(change)="clearResults()">
{{coll.label}}
</mat-radio-button>
</mat-radio-group>
Run Code Online (Sandbox Code Playgroud)
Chrome 控制台中的错误:
ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.
Example 1: <input [(ngModel)]="person.firstName" name="first">
Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">
at Function.TemplateDrivenErrors.missingNameException (forms.js:5891)
at NgModel._checkName (forms.js:6244)
at NgModel._checkForErrors (forms.js:6217)
at NgModel.ngOnChanges (forms.js:6099)
at checkAndUpdateDirectiveInline (core.js:12407)
at checkAndUpdateNodeInline …Run Code Online (Sandbox Code Playgroud) 阅读包括“ Access-Control-Allow-Origin”在内的许多方法,但没有一种对我有用。
我使用@ angular / common / http模块和外部url作为数据源。通过尝试获取数据来获取错误:///// .................
Failed to load http://accounts.......com/accounts: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 503.
Run Code Online (Sandbox Code Playgroud)
account.service.ts:
Failed to load http://accounts.......com/accounts: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 503.
Run Code Online (Sandbox Code Playgroud)
app.module.ts
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { HttpClient, …Run Code Online (Sandbox Code Playgroud)我在我的 Angular5 应用程序中尝试了许多用户名模式。但没有得到适合我要求的解决方案。
最少 6 个字符
只允许使用数字 至少应包含一个字符
不允许使用特殊字符,除了 _
不允许使用空格
只允许使用字符
我试过 /^[a-zA-Z0-9]+([_]?[a-zA-Z0-9])*$/
/^[a-zA-Z0-9][a-zA-Z0-9_]*[a-zA-Z0-9](?<![_\s\-]{6,}.*)$/
Run Code Online (Sandbox Code Playgroud) 我正在使用角5
我使用以下代码创建多个复选框,并需要给它们标签
<input type="checkbox" *ngFor = "let v of options[0].options" [value]="1" [name] = "1">
Run Code Online (Sandbox Code Playgroud)
使用HTML时我会使用
如何在*ngFor中使用标签并创建合适的标签?
谢谢
当我编写以下代码时,我正在使用angular6:
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
EditDetail(data) : Observable<Test[]> {
let url = "http://www.example.com/api/getdetails";
return this.httpClient.get(url).map((response: Response) => {
return <Test[]>response.json();
});
Run Code Online (Sandbox Code Playgroud)
我收到的错误如下:
this.httpClient.get(...).map is not a function
Run Code Online (Sandbox Code Playgroud)
在浏览器控制台中
我也试过了
import { pipe } from 'rxjs';
Run Code Online (Sandbox Code Playgroud)
并使用
return this.httpClient.get(url).pipe(
map((response: Response) => <Test[]>response.json())
);
Run Code Online (Sandbox Code Playgroud)
但它显示错误
this.httpClient.get(...).pipe is not a function
Run Code Online (Sandbox Code Playgroud) 我有json数据,我想将其转换为对象格式以进行创建操作.
JSON
[
{
"user": {
"id": 83,
"username": "das",
"first_name": "dsafha",
"last_name": "dfksdfk",
"email": "sasda@gmail.com",
"is_active": true,
"is_superuser": false
},
"role": "testBu"
},
{
"user": {
"id": 84,
"username": "sadfds",
"first_name": "dshhgds",
"last_name": "fsdjsl",
"email": "fdjgd@gmail.com",
"is_active": true,
"is_superuser": false
},
"role": "testeditrole"
},
{
"user": {
"id": 86,
"username": "fs",
"first_name": "efhks",
"last_name": "sofdh",
"email": "fdshk@gmail.com",
"is_active": true,
"is_superuser": false
},
"role": "testeditrole"
},
{
"user": {
"id": 87,
"username": "xz",
"first_name": "vj",
"last_name": "vkfd",
"email": "sdsl@gmail.com",
"is_active": …Run Code Online (Sandbox Code Playgroud) 我有以下来自api的回复
[
{
"Cinema_strName":"dfdsfsd, Ahmedabad",
"Cinema_strID":"HIWB",
"Cinema_strBannerImg":"F&BCombo.jpg",
"cinema_addr":"fsdfsdfr,Drive-in Road, 380052, ",
"cinema_loc":"<iframe src=\"fsdfsdfdsfsfdsfdsffsf4!2i768!4f13.1!3m3!1m2!1s0x0%3A0x6a9f5938cfed5cd2!2sCarnival+Cinemas!5e0!3m2!1sen!2sin!4v1467809324170\" width=\"600\" height=\"450\" frameborder=\"0\" style=\"border:0\" allowfullscreen></iframe>",
"cinema_mob":0
}
]
Run Code Online (Sandbox Code Playgroud)
我想从api获取iframe并附加到div map
为此,我在TS文件中写道
this.common.createAPIService('api/cinemas/List?CityName='+city, '').subscribe((result: any) => {
if(result.length){
this.cinema = result;
console.log(this.cinema);
}else{
alert('Cinema not found');
}
})
Run Code Online (Sandbox Code Playgroud)
html模板:
<div class="map" *ngFor="let map of cinema">
<div [innerHTML]="map.cinema_loc"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
但是HTML并没有出现,但如果我正常绑定,就像下面那样
<div class="map" *ngFor="let map of cinema">
<div>{{map?.cinema_loc}}</div>
</div>
Run Code Online (Sandbox Code Playgroud)
iframe以文本格式显示.
我如何附加为HTML?
请帮忙.
根据我在下面尝试过的解决方案
this.common.createAPIService('api/cinemas/List?CityName='+city, '').subscribe((result: any) => {
if(result.length){
this.cinema = result;
this.cinema = this.sanitizer.bypassSecurityTrustHtml(this.cinema);
console.log(this.cinema);
}else{
alert('Cinema …Run Code Online (Sandbox Code Playgroud) angular5 ×10
angular ×7
angular6 ×2
javascript ×2
angular-cli ×1
bootstrap-4 ×1
electron ×1
forms ×1
html ×1
http ×1
ngfor ×1
node.js ×1
observable ×1
radio-group ×1
regex ×1
rxjs ×1
spring-boot ×1