Ambiguous $scope on ngAnimate enter/leave_setup.

Unsolved. For animations which share data between enter/leave_setup. AngularJS 1.1.4

by ikaruss

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.4/angular.min.js"></script>
<div ng-app="app" ng-controller="TestCtrl">
    <div ng-repeat="item in items" ng-controller="ItemCtrl" ng-animate=" 'test-animation' "></div>
</div>

JavaScript

// state       | $element.scope()
// ------------|-----------------
// enter_setup | ngRepeat            !
// leave_setup | ngController
// enter_start | ngController
// leave_start | ngController

var animation = function (msg1) {
    var animation = function (msg2) {
        return function ($element) {
            var $scope = $element.scope();
            console.log(msg1 + '_' + msg2, $scope.$id, $scope); // see console
        };
    };

    return function () {
        return {
            setup: animation('setup'),
            start: animation('start')
        };
    };
};

var app = angular.module('app', []);

app.animation('test-animation-enter', animation('enter'));
app.animation('test-animation-leave', animation('leave'));

app.controller('ItemCtrl', function () {});
app.controller('TestCtrl', ['$scope', function ($scope) {
    $scope.items = [{}]; // enter

    setTimeout(function () {
        $scope.$apply(function () {
            $scope.items.pop(); // leave
        });
    }, 0);
}]);