ionic-team / ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
193 stars 187 forks source link

$resolve is undefined when used within an ionView #91

Open jgw96 opened 7 years ago

jgw96 commented 7 years ago

From @TheCopartnery on September 20, 2016 14:58

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 - https://github.com/angular/angular.js/commit/983b0598121a8c5a3a51a30120e114d7e3085d4d

13400 - https://github.com/angular/angular.js/pull/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

Copied from original issue: driftyco/ionic#8140

jgw96 commented 7 years ago

From @mlynch on September 21, 2016 2:15

Thanks for the workaround, we appreciate it and hope it helps others in the meantime.