homerjam/angular-gsapify-router

Get Error: undefined is not an object (evaluating 'state.data')

jake142 opened this issue · 4 comments

I get Error: undefined is not an object (evaluating 'state.data') on line 105 (angular-gsapify-router.js) when I used bower to install. I run it in cordova and had already installed ngAnimation and ui-router (if that makes any difference?).

I can get the demo to run in my cordova app, but not if I try to add it to my app.

Could you post the states you've declared in your app config please?

Which version of angular are you using?

If you could post a stripped down example somewhere that would greatly help.

Thanks

Hi,

I use:

AngularJS v1.4.0
Angular UI routier v0.2.15

This is my routing (I pretty much copied from the demo)

       (function() {
           'use strict';
        angular.module('myapp', ['ngTouch','ngCordova','ngAnimate', 'ui.router', 'hj.gsapifyRouter',     'myapp.controllers'])
      .config(['$stateProvider', '$locationProvider', '$urlRouterProvider', 'gsapifyRouterProvider',
    function($stateProvider, $locationProvider, $urlRouterProvider, gsapifyRouterProvider) {
        gsapifyRouterProvider.defaults = {
            enter: 'slideRight',
            leave: 'slideLeft'
           };
        //...more transitions here

        gsapifyRouterProvider.initialTransitionEnabled = true;
        $urlRouterProvider.otherwise("/");

        $stateProvider.state('signin', {
            url: '/',
            views: {
                main: {
                    templateUrl: 'templates/signin.html',
                    controller: 'SignInCtrl'
                }
            },
            data: {
                'gsapifyRouter.main': {
                    enter: {
                        'in': {
                            transition: 'fadeIn',
                            priority: 1
                        },
                        out: {
                            transition: 'fadeOut',
                            priority: 1
                        }
                    }
                }
            }
        });

        $stateProvider.state('menu', {
            url: '/menu',
            views: {
                main: {
                    templateUrl: 'templates/menu.html',
                    controller: 'MenuCtrl'
                }
            },
            data: {
                'gsapifyRouter.main': {
                    leave: {
                        out: {
                            transition: 'scaleDown',
                            priority: 2
                        }
                    }
                }
            }
        });
    }
]);
angular.module("myapp").run(["$templateCache", function($templateCache) {
    $templateCache.put("templates/menu.html", "<div class=\"wrapper\" style=\"background: #81B270\"><br><br><h1>Menu</h1><br><button ng-click=\"signOut()\">Sign out</button><a href=\"#/\">Sign out</a></div>");
    $templateCache.put("templates/signin.html", "<div class=\"wrapper\" style=\"background: #FF7F40\"><br><br><h1>Sign In</h1><br><button ng-click=\"signIn()\">Sign out</button><a href=\"#/menu\">Menu</a></div>");
}]);
})();

Also, I cant use templates on disk. I have to use $templateCache otherwise I get Error: undefined is not an object (evaluating 'state.data') when the first page loads.

Until I have some more time to test I think it'd be best to revert to angular 1.3. I believe ui-router still has some issues with 1.4 too - mainly due to breaking changes in the way $animate works

Thanks, that solved it.