0

I'm trying to modify eventHandler on fa-pipe-to in my controler but modification is not working.

In my view, i have a 'scroll-view' with a surfaces loop.

Each surface pipe a event handler.

<fa-scroll-view     fa-pipe-from="scrollEventHandler">
    <fa-view    ng-repeat="tile in tiles">
        <fa-modifier    fa-transform="tile.transform">
            <fa-container-surface   fa-pipe-to="tile.eventHandler">
                <fa-modifier    fa-opacity="tile.opacity">
                     <fa-surface   fa-background-color="tile.color"/>
                </fa-modifier>
             </fa-container-surface>
        </fa-modifier>
    </fa-view>
</fa-scroll-view>

In my controller, I have an object with 2 eventHandlers :

function Object() {

    this.eventHandler = null;

    $scope.scrollEventHandler = new EventHandler();
    var dragEventHandler = new GenericSync();

    var activateDragMode = function() {
         this.eventHandler = dragEventHandler;
    }
}

By default I use scrollEventHandler and it works :

this.eventHandler = $scope.scrollEventHandler;

But during execution i want to switch to other eventHandler :

activateDragMode();

So my problem is : when i set new eventHandler to 'eventHandler' variable, eventHandler is not updated.

Does anyone has a solution to do it?

4

1 回答 1

0

OK, i found my error :

When i was debugging 'activateDragMode()' function, i could see that 'this.eventHandler' was undefined, and 'this' was not my Object but was EventHandler.

eventHandler

So, i added .bind(this) to my function to bind the content of my object and everyting was working good :

var activateDragMode = function() {
     this.eventHandler = dragEventHandler;
}.bind(this);
于 2014-10-31T08:15:29.540 回答