I'm trying to update the attribute of a child element of my directive by hovering over one of the other child elements but the scope is not updated. I've referred to What are the nuances of scope prototypal / prototypical inheritance in AngularJS?, but can't figure out why it won't work:
I've tried adding scope.$apply() since it's updated inside the click event, but doesn't seem to work wherever I placed it.
Template:
<div ng-controller="DashboardCtrl">
<svg country>
<path province class="province" id="{{$index}}" ng-attr-d="{{p.d}}" ng-repeat="p in paths">
</path>
<use id="use" ng-xlink-href="#{{current.province}}" />
</svg>
</div>
JS:
angular.module('dashboard').controller("DashboardCtrl", ["$scope", function($scope) {
$scope.paths = [{..snip..}]
}]);
angular.module("map-directive", [])
.directive("country",function () {
return {
restrict: "A",
scope: {},
controller: function ($scope) {
$scope.current = {};
this.hovered = function (province_id) {
$scope.current.province = province_id;
}
}
}
}).directive("province", function () {
return {
require: "^country",
restrict: "A",
link: function (scope, element, attrs, countryCtrl) {
element.on("mouseover", function () {
countryCtrl.hovered(attrs.id);
})
}
}
})