I have 'market' directive:
angular
.module('myModule')
.directive('market', [function () {
return {
restrict: 'EA',
template: '<div outcome="outcome" ng-click="onOutcomeClick()" ng-repeat="outcome in market.Outcomes">{{outcome.Odd}}</div>',
controller: ['$scope', function ($scope) {
$scope.market = {
Outcomes: [
{ Odd: 1 },
{ Odd: 2 },
{ Odd: 3 },
{ Odd: 4 },
{ Odd: 5 },
]
};
}],
link: function (scope, elem, attrs) {
}
}
}]);
which contains many 'outcome' directives:
angular
.module('myModule')
.directive('outcome', [function () {
return {
restrict: 'A',
scope: {
outcome: '='
},
controller: ['$scope', function ($scope) {
$scope.onOutcomeClick = function () {
console.log($scope.outcome.Odd);
};
}],
link: function (scope, elem, attrs) {
}
}
}]);
When I click on "outcome", it seems that angular looks for "onOutcomeClick" in "market" directive, but not in "outcome" directive. How to force angular to call "onOutcomeClick" from "outcome" directive (scope in "outcome" directive must be isolated)
jsfiddle example: http://jsfiddle.net/dgjcf41d/5/ I expect to see alert in example, but fail