angular.tree icon indicating copy to clipboard operation
angular.tree copied to clipboard

Added direct attribute and used $parse for event handling

Open rikkertkoppes opened this issue 12 years ago • 2 comments

I added a direct attribute to be able to prevent the need for modifier keys. E.g.

<ul ng-tree="model" multiple direct>

will always use multiple selection

Furthermore, the $event is now sent along with the select handler. This way, one can do

<ul ng-tree="model">
    <li select="selected($event)">{{item.name}}</li>
</ul>
$scope.selected = function (e) {
    console.log(this.item.name + ' is selected: ' + this.$selected);
    console.log('event',e);
};

rikkertkoppes avatar Mar 20 '13 13:03 rikkertkoppes

Also added an option to redefine the property that is used as selected. this defaults to $selected as before.

<li select="onSelect($event)"
    selected="item.selected">
</li>

Looking at the code, this has been the intention thus far, but never implemented

rikkertkoppes avatar Mar 21 '13 10:03 rikkertkoppes

Looks good. My only comment is that I don't really like having a separate multiple and direct attributes, where direct only serves to modify multiple and has no meaning without it. It seems like multiple should have different values in this case. For example: "key" (the default, equivalent to "true" and ""), "direct", and "false" (equivalent to no attribute). The values "key" and "direct" don't feel very descriptive, but I can't think of anything better.

dump247 avatar Mar 25 '13 18:03 dump247