Sunday, October 1, 2017

Angular 1/ui-router – is undefined Firefox only

when I get to the state project.detail.edit.headers.contact.create.type.overlay.simplified (the last state in the code) I have this error TypeError error: contact.typeRef is undefined

.state({
      name: 'project.detail.edit.headers.contact',
      url: '/contact',
      abstract: true,
      data: {
        skipFooter: true,
        cancelState: 'project.detail.edit.headers'
      },
      views: {
        'overlay@agent.production': {
          component: 'overlayContent'
        }
      },
      resolve: {
        contactTypes: (ContactService) => ContactService.getContactTypes()
      }
    })
    .state({
      name: 'project.detail.edit.headers.contact.create',
      url: '/create',
      abstract: true,
    })
    .state({
      name: 'project.detail.edit.headers.contact.create.type',
      url: '/{type:string}',
      params: {
        type: ContactTypes.physical,
        step: null
      },
      component: 'contactCreatePage',
      resolve: {
        contactType: (contact, contactTypes, $stateParams, ContactService, ContactStepTemplates, UtilService) => {
          let isOpened = null
          if (!contact.typeRef || contact.type !== $stateParams.type) {
            ContactService.switchContactType(contact, $stateParams.type, contactTypes)
            isOpened = (step, index) => !$stateParams.step && index === 0
          }
          UtilService.setStepsTemplate(contact.typeRef.steps, ContactStepTemplates, isOpened)
          return contact.typeRef
        },
        currentStep: (contactType, $stateParams, UtilService) => UtilService.getStepByName(contactType.steps, $stateParams.step)
      }
    })
    .state({
      name: 'project.detail.edit.headers.contact.create.type.overlay',
      url: '',
      abstract: true,
      views: {
        'overlay@agent.production': {
          component: 'overlayContent'
        }
      }
    })
    .state({
      name: 'project.detail.edit.headers.contact.create.type.overlay.simplified',
      url: '/simplified',
      component: 'contactSimplified'
    })

Strangely, it works if I remove the url url: '/simplified', and in the $stateParams.type of the previous state project.detail.edit.headers.contact.create.type becomes physical_contact/simplified, the physical_contact is normal but not with the /simplified.
This problem is only on Firefox and Safari

Angular 1.6.1 – ui-router 1.0.0-rc.1

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/02/angular-1ui-router-is-undefined-firefox-only/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment