Skip to content

$resolve is undefined when used within an ionView #8140

Closed
@Viveur

Description

@Viveur

PROBLEM:

$resolve is undefined when used within an ionView

$resolve should work correctly, just as it does for ngView

WORKAROUND / CODE FIX:

To work around the issue using the current version of Ionic create a file called ionic-overrides.js and add the following code...

  angular.module('app').directive('ionView', function($state) {
    return {
      restrict: 'EA',
      priority: 999999,
      link: function($scope, $element, $attrs, viewCtrl) {
          if ($state.$current && $state.$current.locals) {
              $scope.$resolve = $state.$current.locals.globals;
          }
      }
    };
  });

Link to this file in your index.html just below your script link for app.js.

Functionality added in Angular 1.5.0-rc0

ngView: reference resolved locals in scope, resolveAs: '$resolve'

983b0598 - angular/angular.js@983b059
#13400 - angular/angular.js#13400

INFO

Ionic 1.3.1
Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic CLI Version: 2.0.0
Ionic App Lib Version: 2.0.0-beta.20
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v4.4.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions