小编sag*_*tel的帖子

如何在angular2的表单数组中显示嵌套数组数据?

我已经FormGroup在angular2项目中实现了渲染形式,并且我已经使用formArray了嵌套数组数据

form.component.html

<div class="col-md-12" formArrayName="social_profiles">
  <div *ngFor="let social of resumeForm.controls.social_profiles.controls; let i=index" class="panel panel-default m-t-10">
    <div class="panel-heading" style="min-height: 30px;">
      <span class="glyphicon glyphicon-remove pull-right" *ngIf="resumeForm.controls.social_profiles.controls.length > 1" (click)="removeSocialProfiles(i)"></span>
    </div>
    <div class="panel-body" [formGroupName]="i">
      <social-profile [group]="resumeForm.controls.social_profiles.controls[i]"></social-profile>
    </div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

form.component.ts

export class FormComponent implements OnInit {
    public resumeForm: FormGroup;

    constructor(private formBuilder: FormBuilder) {}

    ngOnInit() {
        this.resumeForm = this.formBuilder.group({
            name: ['', Validators.required],
            label: ['',],
            email: [''],
            phone: [''],  
            social_profiles: this.formBuilder.array([])
        });

        this.addSocialProfiles();
    }

    initSocialProfiles() {
        return this.formBuilder.group({
            network: [''],
            url: …
Run Code Online (Sandbox Code Playgroud)

json angular2-forms angular

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

ng2-ckeditor 错误模块未找到&amp;模块的元数据版本不匹配

我正在尝试ng serve我的 angular 4 项目,我看到了这个

ERROR in /var/www/penderie1/src/app/admin/admin.module.ts (20,32): Cannot find module 'ng2-ckeditor'.
ERROR in /var/www/penderie1/src/app/myaccount/myaccount.module.ts (6,32): Cannot find module 'ng2-ckeditor'.
ERROR in /var/www/penderie1/src/app/app.module.ts (6,32): Cannot find module 'ng2-ckeditor'.
ERROR in Error: Error encountered resolving symbol values statically. Could not resolve ng2-ckeditor relative to /var/www/penderie1/src/app/app.module.ts., resolving symbol AppModule in /var/www/penderie1/src/app/app.module.ts, resolving symbol AppModule in /var/www/penderie1/src/app/app.module.ts
    at syntaxError (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:1729:34)
    at simplifyInContext (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24979:23)
    at StaticReflector.simplify (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24991:13)
    at StaticReflector.annotations (/var/www/penderie1/node_modules/@angular/compiler/bundles/compiler.umd.js:24418:41)
    at _getNgModuleMetadata (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:138:31)
    at _extractLazyRoutesFromStaticModule (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:109:26)
    at Object.listLazyRoutesOfModule (/var/www/penderie1/node_modules/@angular/compiler-cli/src/ngtools_impl.js:53:22)
    at Function.NgTools_InternalApi_NG_2.listLazyRoutes …
Run Code Online (Sandbox Code Playgroud)

npm-install angular

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

标签 统计

angular ×2

angular2-forms ×1

json ×1

npm-install ×1