I am struggling to understand why my ng-click function in my directive is not triggering the fooControls clickTest. Why isn't clickTest logging to the console? Is there a more efficient way to accomplish this?
Custom Directive
app.directive('fooList', function () {
return {
restrict: 'E',
templateUrl: './app/views/fooList.html',
scope: { obj: "=" },
controller: 'fooController',
controllerAs: 'b'
};
});
Controller
app.controller('fooController', ['$scope', function ($scope) {
$scope.obj = [];
$scope.ClickTest = function (num) {console.log(num);};
}]);
HTML Markup
<div ng-repeat="book in obj" class="container">
<div class="row">
<h4 class="pull-right"><button class="btn btn-small" ng-click="b.ClickTest(1)">ClickTest</button></h4>
</div>
<br />
</div>
Edit
The code above is a snippet from the foo-list directive. The complete HTML structure is as follows:
<html>
<head>
</head>
<body>
<foo-list obj="searchResults"></foo-list>
</body>
<html