1

I must create a wizard using angularjs ... I don't know angularjs very well and I know this is a problem... so my doubts are if I am using the correct approch to create the wizard...

Here the main questions I cannot find a answer:

  1. Should I use views or ng-switch or something else I don't know? In this moment, I am using ng-switch, but the main problem I am facing is that every ng-with-when has a own scope;

2.Every step of the wizard need to be filled with some data coming from server. Both using view and ng-switch make impossible to do just a call to the server when i land on the page containing the wizard. It means that everytime a change the step I must call the server and obtain data just for that server. Onestly I don't like that approch, personally I prefer to do just a single call to the server and obtain whatever I need immediately. What do you think about this? I should do a call to the server everytime I change the step? Or is it better do just a call a the start? If second way, is the better, so how should I create the wizard? Because I do not have visibility of the steps following the first, so I cannot do the binding.

Hope I have been clear. Thanks everyone who can help me.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Simone
  • 2,304
  • 6
  • 30
  • 79
  • 1
    This is too broad, and you haven't posted any code, so any answer will probably be incomplete or unsatisfying. You should read a good Angular tutorial before continuing. Some important facts you need to learn: 1. the switch scopes extent the controller scope. So if you have an object in the controller scope, it will be in the switch scope. 2. You can store data in a service, and get the data from this service every time you go to the next step. No need to get the same data from the server again and again. – JB Nizet Jan 04 '16 at 19:37
  • nothing says you can't have all the data available right at step 1 no matter what approach you use – charlietfl Jan 04 '16 at 19:44
  • I've done a couple wizards in Angular, with both UI-Router and just using ng-if and some $scope var to keep track of the current page. I've found that UI-Router is helpful for a few reasons 1) You get URLs to each step, so you can reload the steps 2) You can use the ui router state resolves to resolve and data the step requires, ajax or otherwise 3) Seperate controllers and views for each step, keeps code much cleaner. – officert Jan 04 '16 at 20:24

1 Answers1

3

I implemented a wizard a while ago. I had 5 steps and each step had lots of data. I decided to use UI-Router because I wanted different html template file, separate scope and controller, validation on each step.

by the way there are wizards ready to use on the web. I find them insufficient but maybe for you it will do.

Avi
  • 1,924
  • 3
  • 17
  • 31