homerjam / angular-gsapify-router

Angular UI-Router animation directive allowing configuration of GSAP state transitions based on priority
http://homerjam.github.io/angular-gsapify-router/
MIT License
85 stars 16 forks source link

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

Closed jake142 closed 9 years ago

jake142 commented 9 years ago

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.

homerjam commented 9 years ago

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

jake142 commented 9 years ago

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.

homerjam commented 9 years ago

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

jake142 commented 9 years ago

Thanks, that solved it.