我正在从教程(https://angular.io/tutorial/toh-pt4#inject-message-service)学习新的角度.在添加服务后运行应用程序时我陷入了困境
../node_modules/rxjs/Rx"'没有''的导出成员'.
hero.service.ts
---------------------
import { Injectable } from '@angular/core';
// import { Observable, of } from 'rxjs';
import { Observable, of } from 'rxjs/Observable';
import { Hero } from './hero';
import { HEROES } from './mock-heroes';
import { MessageService } from './message.service';
@Injectable()
export class HeroService {
constructor(private messageService: MessageService) { }
getHeroes(): Observable<Hero[]> {
// TODO: send the message _after_ fetching the heroes
this.messageService.add('HeroService: fetched heroes');
return of(HEROES);
}
}
Run Code Online (Sandbox Code Playgroud)
我的Angular版本和相关信息是
Angular CLI: 1.7.4
Node: 6.14.1 …Run Code Online (Sandbox Code Playgroud) 在 LazyFrame 上使用 sink_parquet 时出现以下错误。早些时候,我使用.collect()的输出scan_parquet()将结果转换为 DataFrame,但不幸的是它不适用于大于 RAM 的数据集。这是我收到的错误 -
PanicException: sink_parquet not yet supported in standard engine. Use 'collect().write_parquet()'
Run Code Online (Sandbox Code Playgroud)
在 LazyFrame 上添加一些过滤器和连接条件后,我尝试将 LazyFrame(scan_parquet 的输出)写入本地文件。错误似乎来自以下位置 -
我已尝试更新到最新版本0.15.16 0.16.1 但此问题仍然存在。
示例代码:
pl.scan_parquet("path/to/file1.parquet")
.select([
pl.col("col2"),
pl.col("col2").apply( lambda x : ...)
.alias("splited_levels"),
..followed by more columns and .alias()
])
.join(<another lazyframe>,on="some key",how="inner")
.filter(...)
.filter(..)
..followed by some more filters
.sink_parquet("path/to/result2.parquet")
Run Code Online (Sandbox Code Playgroud)
parquet 文件应写入本地系统中。相反,我收到以下错误 -
PanicException: sink_parquet not yet supported in standard engine. Use 'collect().write_parquet()'
Run Code Online (Sandbox Code Playgroud)
以下是我使用后安装的软件包的详细信息polars.show_versions() …
var arr = [obs1, obs2, obs3];
Observable.forkJoin(...arr).subscribe(function (observableItems) {})
Run Code Online (Sandbox Code Playgroud)
并行运行observable并返回一个数组.
如何顺序运行observable 并返回一个数组.我不想为每个观察者打电话,所以concat()不适合我.
我想收到相同的最终结果,forkJoin但顺序运行.
它存在吗?或者我必须编写自己的可观察模式?
我检查了各种来源,但大多数解决方案都在jQuery中。如果可能的话,我希望在Typescript中提供解决方案。
HTML-
<input #coverFilesInput class="file-input" type="file"(change)="onChange($event)"....>
打字稿-
onChange($event) { let img = event.target.files[0]; // and then I need code to validate image size }
Run Code Online (Sandbox Code Playgroud)
有解决方案还是我做错了?
我处于一种情况,我想使用Proxy, 在类列表之间“负载平衡”。
我想做的一个简单的例子如下:
class Foo {
constructor(private msg: string) {}
foo() {
console.log(this.msg);
}
}
// @ts-ignore
const proxy: Foo = new Proxy([new Foo('foo'), new Foo('bar')], {
get: (o, key) => {
const client = o[Math.floor(Math.random() * o.length)];
console.log(client, key);
return client[key];
},
});
proxy.foo();
Run Code Online (Sandbox Code Playgroud)
这“有效”。问题是我正在使用打字稿。而且,由于Proxy类型定义,我们不能做类似的事情
new Proxy<Foo>([new Foo(), new Foo()], handler)
Run Code Online (Sandbox Code Playgroud)
因为它会产生以下错误:
“Foo[]”类型的参数不可分配给“Foo”类型的参数。
有没有办法实现这一点;不丢失类型检查?
import { Injectable } from '@angular/core';
import { Http, Response,Headers,RequestOptions } from '@angular/http';
import { Observable } from 'rxjs';
import 'rxjs/Rx';
import{Router} from'@angular/router';
import 'rxjs/add/operator/map';
@Injectable()
export class ManageJobDeleteService{
constructor(private http: Http,private router:Router){};
DeleteRequestToAPI(post_jobs_id:string){
let body = JSON.stringify({post_jobs_id:post_jobs_id});
let headers = new Headers({ 'Content-Type': 'application/json'});
let options = new RequestOptions({ headers: headers });
console.log(body);
console.log(options);
return this.http.delete('http://127.0.0.1:8000/api/employer/post_jobs/',body,options)//HERE I AM GETTING ERROR
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response){
let body = res.json();
console.log(body);
return body || [];
}
private handleError …Run Code Online (Sandbox Code Playgroud) 我正在动态创建元素,其中一个元素使用@Inject解析为工厂的令牌。
问题在于工厂实例缓存在节点索引上。一旦我的元素从视图中消失并返回,我希望能够调用我的工厂函数;但我不。相反,我得到了这个工厂实例的缓存版本。
如何确保对象从视图中消失后不使用缓存?
基本上,当我的@Component构造函数被调用时,我期望一个全新的服务。不是缓存服务。
@Inject(FORM_GROUP_MANAGER_SERVICE)
private formGroupManagerService: FormGroupManagerServiceImpl
Run Code Online (Sandbox Code Playgroud)
{
provide: FORM_GROUP_MANAGER_SERVICE,
useFactory: (structureControlService, createTonicControlFactory, parent) => new FormGroupManagerService(
structureControlService,
createTonicControlFactory,
parent
),
deps: [StructureControlService, FORM_GROUP_MANAGER_SERVICE_CREATE_CONTROL, [new Optional(), FormGroupManagerService]]
},
Run Code Online (Sandbox Code Playgroud) ADFS 和 Azure AD 之间的差异
据我了解,ADFS 是一种 STS(安全令牌服务),因为它向应用程序颁发令牌,帮助应用程序建立用户身份。在组织级别,我们的组织使用 ADFS 和 WS-Federation 协议来对组织所有内部应用程序中的用户进行身份验证,并实施 SSO。
此外,在我们的组织中,我们有 Azure AD 帐户,并且我使用 Azure AD 来注册我们的自定义应用程序,每当未经身份验证的用户进入我们的应用程序时,该人将重定向到 azure ad 登录页面,并且必须对自己进行身份验证。身份验证成功后,Azure AD 还会颁发令牌(ID 令牌、访问令牌、刷新令牌)
我的问题是,我是否可以将 Azure AD 视为一种 STS(安全令牌服务),就像 ADFS 一样,因为它会颁发令牌来建立客户端身份?
我当前的文件夹路径是$path = car_images;
它对我有用。我可以直接将我的图片上传到这个文件夹中。但我想为每个用户创建单独的文件夹。所以现在图像应该上传到$path = car_images/$emp_code;
意味着我想首先$emp_code在car_images文件夹中创建名称为目录的目录,然后将$emp_code图像上传到目录中。
我当前的代码没有在 car_images 文件夹中创建目录。
$path = "car_images/".$emp_code;
if (!is_dir($path.'/'.$emp_code))
{
mkdir($path.'/'.$emp_code, 0777, true);
}
$name = $_FILES['car_images']['name'][$i];
$size = $_FILES['car_images']['size'][$i];
list($txt, $ext) = explode(".", $name);
$file= time().substr(str_replace(" ", "_", $txt), 0);
$info = pathinfo($file);
$filename = $file.".".$ext;
if(move_uploaded_file($_FILES['car_images']['tmp_name'][$i], $path.$filename))
{
$file_name_all.=$filename.",";
}
Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试在我的有角项目中使用socket.io。我要显示的三个文件是组件文件,一个服务文件和一个模块文件。每当我在组件文件中使用服务时,都会得到静态注射器错误。这是:
错误:StaticInjectorError(AppModule)[AppComponent-> WrappedSocket]:StaticInjectorError(平台:核心)[AppComponent-> WrappedSocket]:
NullInjectorError:WrappedSocket没有提供者!
这是组件文件:
import { Component } from '@angular/core';
import { cheema2 } from './practice.service';
import { Injectable } from '@angular/core';
import { Socket } from 'ng-socket-io';
@Component
({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
@Injectable()
export class AppComponent
{
constructor(private socket: Socket) { }
sendMessage(msg: string){
this.socket.emit("message", msg);
}
getMessage()
{
console.log( this.socket.fromEvent("message"));
}
}
Run Code Online (Sandbox Code Playgroud)
这是模块文件
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { SocketIoModule, SocketIoConfig } from 'ng-socket-io'; …Run Code Online (Sandbox Code Playgroud) 我有一个从docker获取JSON的服务。我想获取容器的数量。
因此,我订阅了我的服务:
ngOnInit() {
this.docker.getContainers().subscribe(containers => {
console.log(containers.length);
});
}
Run Code Online (Sandbox Code Playgroud)
我在控制台上得到了正确的答案,但是我得到了:
类型对象上不存在属性长度
难道我做错了什么?
export class DockerService {
private baseUrl:string = 'http://localhost:8080/api/docker';
private headers = new HttpHeaders({'Content-Type':'application/json'});
private options = new HttpHeaderResponse({headers:this.headers});
constructor(private _http:HttpClient) { }
getContainers() {
return this._http.get(this.baseUrl + "/containers", this.options);
}
getImages() {
return this._http.get(this.baseUrl + "/images", this.options);
}
}
Run Code Online (Sandbox Code Playgroud) 我需要使用httpclient进入foreach循环。有可能的?正确的方法是什么?这是我的代码:
this.attachToDelete.forEach(
element => {
this.documentService.DeleteAttachment(element, this.newDocumentId.toString());
console.log("upload delete from submit", element);
}
);
Run Code Online (Sandbox Code Playgroud)
这是对应服务中的方法:
public DeleteAttachment(attachmentId: number, documentId: string) {
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json; charset=utf-8');
return this.http.post('http://localhost:8080/DocumentAPI/api/document/RemoveAttachment?docId=' + documentId + '&attachmentId='+attachmentId, attachmentId, { headers: headers }).subscribe(
data => {
if(data)
console.log("delete attach????", data);
else{
console.log('Error occured');
}
}
);
}
Run Code Online (Sandbox Code Playgroud) angular ×7
typescript ×5
rxjs ×3
adfs ×1
angular5 ×1
angular6 ×1
angular7 ×1
azure ×1
call ×1
ecmascript-6 ×1
file-upload ×1
httpclient ×1
javascript ×1
observable ×1
parquet ×1
php ×1
post ×1
rest ×1
sockets ×1
upload ×1