Trying to think about how to build a multi step form in angular 2

后端 未结 2 589
情书的邮戳
情书的邮戳 2021-02-02 15:46

I am trying to build a small, 3 step form. It would be something similar to this:

The way I did this in react was by using redux to track form completion and r

2条回答
  •  梦如初夏
    2021-02-02 16:16

    If you want to keep things extensible, you could try something like this:

    
      
      
      
      
      
      
     
    
     export class SignUpVm {
       createAccount: CreateAccountVm; //Contains your fields & finished bool
       socialProfiles: SocialProfilesVm; //Contains your fields & finished bool
       personalDetails: PersonalDetailsVm; //Contains your fields & finished bool
       //Store index here if you want, although I don't think you need it
     }
    
     @Component({})
     export class SignUp {
       model = new SignUpVm(); //from sign_up_vm.ts (e.g)
     }
    
     //Copy this for personalDetails & createAccount
     @Component({})
     export class SocialProfiles {
       @Input() model: SignUpVm;
     }
    

提交回复
热议问题