我知道通过以下几行代码,我们可以获得域名,但不确定如何获得端口号。有人能帮帮我吗?
//importing
import { DOCUMENT } from '@angular/platform-browser';
//Injection
export class domainUtil {
domain:string;
constructor(@Inject(DOCUMENT) private document: any) { }
returnHostname(){
this.domain = this.document.location.hostname;
console.log("*****Domain Name*******"+this.domain);//Returning domain name
}
}发布于 2018-10-01 15:36:15
document.location.port
在angular中,它将是
this.port = this.document.location.port;https://stackoverflow.com/questions/52586437
复制相似问题