I cannot figure out why my ng-click inside of my directive will not fire the fooControls clickTest. Why is clickTest not firing and logging to the console? is there a better way of doing this?
Directive
app.directive('fooList', function () {
return {
restrict: 'E',
templateUrl: './app/views/fooList.html',
scope: { obj: "=" },
controller: 'fooController',
controllerAs: 'b'
};
});
Controler
app.controller('fooController', ['$scope', function ($scope) {
$scope.obj = [];
$scope.ClickTest = function (num) {console.log(num);};
}]);
HTML
<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 above html is a copy paste of foo-list. The full html is
<html>
<head>
</head>
<body>
<foo-list obj="searchResults"></foo-list>
</body>
<html
<foo-list>tag is not even used...b.ClickTest(1). You have ClickTest applied to your scope, it should just beClickTest(1)