JavaScript Redirect from within Angular controller if condition is met at start of page redirect from within iframe,redirect page from within iframe,redirect

I have an Angular app used to track hours worked by the user. When the user adds a new job, they are taken through a wizard, with each page/controller adding a new property to the job object. Once the wizard is complete, the user can start tracking by navigating to the jobs home page from the app main page.

It is, however, possible to exit the wizard before it is completed (via the back button) and then navigate to the home page of the job. What I need is for the controller for that home page to redirect to the appropriate wizard page for whichever job property is missing.

The job variable is retrieved from local storage at the start of the controller code.

var job = DatastoreService.objectJob();
    job.initFromHash($routeParams.jobHash);


function checkJobProps(prop, route){
        if(!job.data.hasOwnProperty(prop))
            $location.path('/wizard/add-position/' + $routeParams.jobHash + '/' + route);
    }

    checkJobProps('taxSettings', 'tax');
    checkJobProps('payrollSettings','payroll-opt');
    checkJobProps('breaks', 'breaks');
    checkJobProps('allowances', 'allowances');
    checkJobProps('deductions', 'deductions');
    checkJobProps('generalSettings', 'general-settings');

There is code below this on the controller that breaks if certain properties are not available. None of these function calls execute fast enough to prevent errors. They will redirect, but not elegantly and it will also always be the last one in the list that takes effect.

Do I do this with a promise? The navigation that is used from the home page of the app to the home page of each job is a directive so, I guess it may be possible to init the job from the $routeParams.jobhash and check these properties within the directive, but I would have to learn more about directives first.

Any help would be much appreciated.

Answer:1

i have two tabs, one shows some hotel names from one location and other tab shows some hotels from another location. and when i select one hotel from one tab and then another from another tab. the ...

i have two tabs, one shows some hotel names from one location and other tab shows some hotels from another location. and when i select one hotel from one tab and then another from another tab. the ...

  1. total cost based on
  2. total cost activity based costing
  3. total cost of marriage based green card
  4. total cost of employment based green card
  5. total cost using activity based costing
  6. total cost of care population-based pmpm index
  7. total manufacturing cost activity based costing

Please be nice. My first question here. I'm learning JavaScript and jQuery. Google isn't much help because I don't know how to ask the right question. Need human intervention please. I'm trying to ...

Please be nice. My first question here. I'm learning JavaScript and jQuery. Google isn't much help because I don't know how to ask the right question. Need human intervention please. I'm trying to ...

  1. javascript variable equals function
  2. javascript variable equals or
  3. javascript variable equals function return
  4. javascript variable equals multiple values
  5. javascript variable equals another variable
  6. javascript variable equals true
  7. javascript variable equals string
  8. javascript variable equals
  9. javascript variable equals undefined
  10. javascript variable equals curly braces
  11. javascript variable equals null
  12. javascript variable equals array
  13. javascript variable equals switch
  14. javascript variable equals number
  15. js variable equals function
  16. js variable equals switch
  17. js variable equals or
  18. javascript variable comparison
  19. js variable comparison
  20. javascript if variable equals

new Array // outputs [] [] // outputs [] But new Array === [] is false. Why so? console.log(new Array === [])

new Array // outputs [] [] // outputs [] But new Array === [] is false. Why so? console.log(new Array === [])

I've written a function to turn a string such as 'aaazeeeee' into a new string of 'aaa z eeeee' this is the code I've tried that works const groupCharacters = signature => { let ...

I've written a function to turn a string such as 'aaazeeeee' into a new string of 'aaa z eeeee' this is the code I've tried that works const groupCharacters = signature => { let ...

  1. refactoring with function