首页 > 解决方案 > 刷新页面后变为空白(AngularJS 状态)

问题描述

当我单击主页上的按钮时,它会转到正确的页面并正确加载所有数据。但在那之后,当我刷新页面数据时,不会加载并显示空白页面。

下面显示我的状态路由器功能。

.state 'opportunity.new.connections',
    url: '/connections/:connectionType'
    params:
      opportunityId: null
      opportunity: null
      connectionType: null
      activeDropDown: null
    template: '<opp-profile-custom-object-connection
                  connections="connections"
                  custom-object-type="customObjectType"
                  custom-connection-types="customConnectionTypes"
                  custom-object="customObject"
                ></opp-profile-custom-object-connection>'
    controller: ['$scope', 'connections', 'customObjectType', 'customConnectionTypes', 'customObject',
      ($scope, connections, customObjectType, customConnectionTypes, customObject) ->
        $scope.connections = connections
        $scope.customObjectType = customObjectType
        $scope.customConnectionTypes = customConnectionTypes
        $scope.customObject = customObject
    ]
    resolve:
      connections: ['clickConnections', '$stateParams', (clickConnections, $stateParams) ->
        opportunity =
          id: $stateParams.opportunityId

        clickConnections.getConnectionsByOpportunityAndType(opportunity, $stateParams.connectionType).then (response) ->
          response
        .catch ->
          $state.go 'notFound'
      ]
      customObjectType: ['$stateParams', 'clickApi', '$q', '$state', ($stateParams, clickApi, $q, $state) ->
        clickApi.getData '/custom-object-types', null, { query: 'canonicalPlural="' + $stateParams.connectionType + '"' }
        .then (response) ->
          response.data._embedded.customObjectTypes[0]
        .catch ->
          $state.go 'notFound'
      ]
      customConnectionTypes: ['$stateParams', 'customConnectionTypeService', 'CONNECTION_TYPE_OPPORTUNITY', 'customObjectType', ($stateParams, customConnectionTypeService, CONNECTION_TYPE_OPPORTUNITY, customObjectType) ->
        customConnectionTypeService.getCustomConnectionTypesByFromAndToCategory(CONNECTION_TYPE_OPPORTUNITY, 'object' +  customObjectType.id)
      ]
      customObject: ['clickCustomObjects', 'customObjectType', (clickCustomObjects, customObjectType) ->
        clickCustomObjects.getSelect2AjaxConfig
          multiple: false
          newable: ['customObject']
          customObjectTypeId: customObjectType.id

      ]
      activeDropDown: ['$stateParams', 'profileTabService', 'customObjectType', ($stateParams, profileTabService, customObjectType) ->
        if $stateParams.activeDropDown then return $stateParams.activeDropDown

        profileTabService.getLastAccessedConnectionType('opportunities', "object#{customObjectType.id}", null).then (selection) ->
           $stateParams.activeDropDown = selection || 'standard'
      ]

谢谢!

标签: javascriptangularjsroutesstate

解决方案


推荐阅读