我在本地桌面上为Kubernetes使用Docker Desktop for mac。我正在尝试连接到安装在 pod 中的本地机器上的数据库,但无法确定主机地址应该是什么。我如何与我的机器在 pod 中的地址相关联?
请注意,我无法使用机器的 ip,因为 db 端口在我的网络中被阻止。
我正在尝试借助Angular的教程https://angular.io/guide/http创建服务
我正在使用Angular 7.0.7。
该服务将从某些网址获取json数据:
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Injectable
export class ProductListService {
constructor(private http: HttpClient) {
}
productListUrl: string = "https://blahblah.com/products";
getProductList() {
return this.http.get(this.productListUrl);
}
}
Run Code Online (Sandbox Code Playgroud)
我在@Injectable()该问题的标题下出现了弯曲的线条。为什么会发生这种情况,我该如何解决?
我有一个将使用此服务的组件:
import { ProductListService } from '../services/productList.service';
@Component({
selector: 'app-productlist',
templateUrl: './productlist.component.html',
styleUrls: ['./productlist.component.css'],
providers: [ProductListService]
})
Run Code Online (Sandbox Code Playgroud) 我有 2 个使用docker-compose. 一个带有python和 的后端,一个带有php和 的网络apache。我的.yaml文件如下所示:
services:
web:
build: ./php
container_name: php_web
volumes:
- ./php/:/var/www/html/
ports:
- "8100:80"
stdin_open: true
tty: true
python:
build: ./python
volumes:
- ./product:/user/src/app
ports:
- "5000:5000"
Run Code Online (Sandbox Code Playgroud)
我希望能够从 python 访问 Web 容器文件系统,反之亦然,这样它们就可以共享文件。
有没有一种简单的方法可以使用 docker compose 来做到这一点?
我试图以角度7传递一个来自api的地图,从父到子组件.
parent.ts:
export class AppComponent {
title = 'taurs-frontend';
categories: any;
isLoggedIn = false;
ngOnInit(){
this.roomDataService.getData(`${environment.api_url}/api/Categories`)
.subscribe(categories => {
this.categories=categories
});
}
Run Code Online (Sandbox Code Playgroud)
parent.html:
<app-room-card [categories]="categories"></app-room-card>
Run Code Online (Sandbox Code Playgroud)
child.ts:
@Component({
selector: 'app-room-card',
templateUrl: './room-card.component.html',
styleUrls: ['./room-card.component.css']
})
export class RoomCardComponent implements OnInit {
@Input('categories') catname: any;
ngOnInit() {
console.log('aaa'+ this.catname);
}
// ..
}
Run Code Online (Sandbox Code Playgroud)
当我尝试记录变量时catname,它是未定义的.如果我尝试从父项导入变量标题,一切正常.如何将类别传递给子项,并使用API调用中的值填充它?
我有两个组件和一个服务。我想使用该服务来存储一个公共值。StripeComponent设置服务中的值。我收到以下错误:
无法读取未定义的属性“setAddress”
这是我的组件:
import { Component, ViewChild, OnInit } from '@angular/core'
import { NgForm } from '@angular/forms'
import { Address } from '../_models/address'
import { Observable } from 'rxjs';
import { ConfigService } from '../_services/config.service';
declare var Stripe;
@Component({
selector: 'app-stripe',
templateUrl: './stripe.component.html',
styleUrls: ['./stripe.component.css'],
providers: [ConfigService]
})
export class StripeComponent implements OnInit {
public address =
new Address(
{
name:"",
address_city: "",
address_line1: "",
address_line2: "",
address_state: "",
address_zip: "",
address_country: ""
}
)
configService: ConfigService
constructor() …Run Code Online (Sandbox Code Playgroud) 我正在尝试将1980-02-22T00:00:00Z解析为"java.util.Date"使用
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'").parse(stringdate)
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
由以下原因引起:java.text.ParseException:无法解析的日期.
如何将这样的字符串解析为Date以获得时间(以毫秒为单位)?我试过用SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'")和SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")
angular ×3
angular7 ×3
typescript ×3
docker ×2
date ×1
java ×1
kotlin ×1
kubernetes ×1
macos ×1
parent-child ×1