小编Ahe*_*elp的帖子

在 nginx 服务器中为 Angular 5 应用程序配置子文件夹

我有两个角度应用程序发布到两个不同的子文件夹“testapp1”和“testapp2”。

url's - 
    https://dev.testurl.org/foo -- For testapp1
    https://dev.testurl.org/bar -- For testapp2
Run Code Online (Sandbox Code Playgroud)

所以我用basehref构建角度

For testapp1:
 ng build --prod --base-href /foo/ 

For testapp2:
  ng build --prod --base-href /bar/
Run Code Online (Sandbox Code Playgroud)

我的 nginx 配置,

server {
  listen 80 default_server;
  listen [::]:80 default_server;

  client_max_body_size 1000M;
  server_name dev.testurl.org localhost;

  location /testapp1/ {
            autoindex on;
    root /testapp1/dist;
    try_files $uri $uri/ /foo/index.html;    
  }
  location /testapp2/ {
            autoindex on;
    root /testapp2/dist;
    try_files $uri $uri/ /bar/index.html;    
  }
Run Code Online (Sandbox Code Playgroud)

当我尝试点击https://dev.testurl.org/foo或 /bar 时,它有控制台错误,显示“意外语法错误”,基本上它没有加载正确的源。任何想法?我是否正确构建应用程序或做了错误的 nginx 配置?

nginx amazon-ec2 amazon-web-services angular

5
推荐指数
1
解决办法
7193
查看次数

在 Angular 6 中将默认值设置为 formArray

联系方式,

interface Contact {
  name:string;
  age:number;
}
Run Code Online (Sandbox Code Playgroud)

联系人组件,用值初始化的联系人数组,

export class ContactComponent {

 contacts: Contact[] = [{name:'xyz', age:30}, {name:'abc', age: 25}];
 contactForm: FormGroup;

 constructor(private fb: FormBuilder) {
  this.contactForm = this.fb.group({
   contacts: this.fb.array([this.createContact()])
  });
 }

 createContact(): FormGroup {
    return this.fb.group({
       ???????? - How can initialize values here. 
    });
 }

}
Run Code Online (Sandbox Code Playgroud)

还有其他更好的设计方法吗?

angular

3
推荐指数
1
解决办法
9672
查看次数

如何在 Angular 中 patchValue 时防止/停止 valuechanges 事件

您可以通过代码示例在这里找到我的问题 https://stackblitz.com/edit/angular-vhrppl?embed=1&file=src/app/app.component.html

我想在 patchValue 时阻止 valuechange 订阅,因为这两个值都订阅了 valuechange 并覆盖了计算结果。

我相信这应该是应用程序中的常见用例,是否有 RxJS 运算符来处理这种情况或有更好的设计?

rxjs angular angular-forms

1
推荐指数
1
解决办法
4782
查看次数