javascript - In Angular, Communicating a matching $index between two different directives -



javascript - In Angular, Communicating a matching $index between two different directives -

i have 2 directive:

<wa-svg ng-repeat="page in pages" ng-mouseover="showtooltip($index)> <wa-tooltip ng-repeat="page in pages" ng-class="{on: matchedindex}">

question:

on mouseover of specific wa-svg how match $index of wa-svg create matchedindex of wa-tooltip homecoming true. thus, class of ongets appended wa-tooltip

i believe take isolate scope or maybe possible through ng-model it's confusing.

note: i cannot nest these elements because wa-svg svg object , cant nest unless using foreignobject , blah blah blah.

hmm how shared controller then?

a wrapper controller has function:

$scope.showtooltip= function($index) { $scope.hoveredindex = $index; }

and in tooltip directive do:

<wa-tooltip ng-repeat="page in pages" ng-class="{on: $index === hoveredindex}">

will work you?

javascript angularjs angularjs-scope angularjs-ng-repeat directive

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -