我刚开始学习Angular 2我正在尝试使用get调用来访问URL,但是即使在浏览器的网络中,get似乎也没有通过我无法找到获取URL的URL.
该程序将进入上面和下面的方法控制台记录,但是get调用没有任何内容
我的服务方式
import { Headers, Http, Response } from '@angular/http';
import { Injectable } from '@angular/core';
import { Persons } from './mock-people';
import { Person } from './person';
import {Observable} from 'rxjs/Rx';
getAllPersons(): void {
console.log("Here");
this.http.get(`http://swapi.co/api/people/1`)
.map((response: Response) => {
console.log(response.json());
response.json();
});
console.log("Comes here 2");
}
Run Code Online (Sandbox Code Playgroud)
进口HttpModule在app.module.ts
我的控制台屏幕截图
![安慰]](https://i.stack.imgur.com/w9AeE.png)
我收到以下错误:
Angular 2 - EXCEPTION:错误:资源URL上下文中使用的不安全值
是否与在启动时不立即使用媒体项目有关?或者它与URL不安全有关?我正在努力消毒它.
export class HomeComponent {
sanitizer: DomSanitizationService;
errorMessage: string;
activeMedia: MediaItem = new MediaItem(0, '', '', '', '', '', '');
constructor(
private mediaStorage: MediaStorageService,
private harvesterService: HarvesterService,
sanitizer: DomSanitizationService) {
this.sanitizer = sanitizer;
// Initial call -
harvesterService.getMediaItems(10, 'type', 'category');
let subscription = harvesterService.initialMediaHarvestedEvent.subscribe(() => {
this.activeMedia = mediaStorage.mediaList[0];
let newURL = this.activeMedia.URL + '?rel=0&autoplay=1';
newURL = newURL.replace('watch?v=', 'v/');
this.activeMedia.URL = newURL; //sanitizer.bypassSecurityTrustUrl(newURL);
console.log(newURL);
});
}
cleanURL(oldURL: string): SafeResourceUrl {
return this.sanitizer.bypassSecurityTrustUrl(oldURL);
}
}
Run Code Online (Sandbox Code Playgroud)
模板代码是: …
我跑了:composer require mongodb/mongodb.但它给了我以下错误:
有错误:
Run Code Online (Sandbox Code Playgroud)- mongodb/mongodb 1.0.1 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system. - mongodb/mongodb 1.0.0 requires ext-mongodb ^1.1.0 -> the requested PHP extension mongodb is missing from your system. - Installation request for mongodb/mongodb ^1.0 -> satisfiable by mongodb/mongodb[1.0.0, 1.0.1].
我试过了 : composer show -p
然后它给了我:
......
ext-iconv 0 The iconv PHP extension
ext-mcrypt 0 The mcrypt PHP extension
ext-mhash 0 The mhash PHP extension
ext-mongo 1.6.12 The mongo …Run Code Online (Sandbox Code Playgroud) 我有一份以下表格的文件:
{
"_id" : ObjectId("4d2d8deff4e6c1d71fc29a07"),
"user_id" : "714638ba-2e08-2168-2b99-00002f3d43c0",
"events" : [
{
"profile" : 10,
"data" : "....."
}
{
"profile" : 10,
"data" : "....."
}
{
"profile" : 20,
"data" : "....."
}
...
]
}
Run Code Online (Sandbox Code Playgroud)
我想upsert发表一些声明.它需要一个添加event到events阵列user_id中的情况下,已经有这样的文档存在,否则就需要创建与该文档event项.
可以这样做吗?
我正在使用PowerShell向a发送POST请求REST API.请求的主体如下所示:
{
"title": "game result",
"attachments": [{
"image_url": "http://contoso/",
"title": "good work!"
},
{
"fields": [{
"title": "score",
"value": "100"
},
{
"title": "bonus",
"value": "50"
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud)
现在,以下PowerShell脚本生成错误的输出:
$fields = @(@{title='score'; value='100'},@{title='bonus'; value='10'})
$fieldsWrap = @{fields=$fields}
#$fieldsWrap | ConvertTo-Json
$attachments = @(@{title='good work!';image_url='http://contoso'},$fieldsWrap)
$body = @{title='game results';attachments=$attachments}
$json = $body | ConvertTo-Json
$json
Run Code Online (Sandbox Code Playgroud)
第3行(如果未注释)产生正确的输出,但是第7行产生:
{
"attachments": [{
"image_url": "http://contoso",
"title": "good work!"
},
{
"fields": "System.Collections.Hashtable System.Collections.Hashtable"
}
],
"title": "game …Run Code Online (Sandbox Code Playgroud) 我有一个非常复杂且庞大的数据,我必须在组件中围绕它构建一个Reactive表单。
我已经开发了表格。但是,当我在其中一个input字段中键入内容以编辑填充的数据时,它在更新该字段的值时响应非常慢。
我尝试使用updateOn:'blur','submit'但没有任何运气。
我的问题是,处理大数据表格的最佳实践是什么?
更新:这是我的StackBlitz。
注意:我已经为我的实际实现创建了一个非常小的版本,并且在Reactive Form中存在性能问题。
我有一个字段_id有类型的文档,ObjectId字段created_at有类型Date.
_id当然是增加,created_atcurrent_date 的值应该增加.
所以我的问题是:
A._id > B._id,但是A.created_at < B.created_at.created_at尽可能精确,所以顺序created_at对应_id.我正在Angular上建一个项目,这个项目将有很多图像作为设计的一部分.我想知道是否可以保留组件中每个组件使用的图像,而不必从assets文件夹中获取每个图像.
我想知道是否可以配置Angular来容纳和提供该组件中组件使用的图像.
见图片澄清:

我必须确定页面是否由于某些路由而刷新或加载。
我认为可以通过ing 到路由器事件来使用 AngularRouter的NavigationEnd事件。subscribe
有人知道该怎么做吗?
请不要使用纯 JavaScript 解决方案。
我正在使用Mac版本10.13.6。
我想通过终端编译C程序。我已经下载了Xcode和命令行工具。当我clang --version在终端中键入时,收到以下两个错误消息:
clang:错误:无法找到xcodebuild,请确保正确设置了Xcode文件夹的路径!
clang:错误:您可以使用/ usr / bin / xcode-select -switch设置Xcode文件夹的路径
我做了一些谷歌搜索,然后在这里找到了解决方法。解决方案是在终端中运行以下行:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
我做到了 但是当我clang --version这样做之后进入时,我会得到完全相同的两个错误。这是怎么回事?
注意:这是非常新的内容,因此在回答时请记住这一点!干杯
angular ×5
mongodb ×3
angular-http ×1
arrays ×1
c ×1
composer-php ×1
javascript ×1
json ×1
macos ×1
performance ×1
powershell ×1
typescript ×1
ubuntu ×1
upsert ×1
xcode ×1