Given this simple Angular module:
angular.module('fixturesModule', [])
.directive('clubfixtures', function () {
"use strict";
return {
restrict: 'E',
replace: true,
transclude: true,
scope: {
club : "@club",
max : "@max"
},
templateUrl: "ClubResultsTemplate.html",
controller: function ($scope, $http) {
$http.get("data.json").success(function (data) {
$scope.results = data;
});
$scope.sortBy = "Date";
}
}
});
How do I access club and max in the controller function?
Thanks,
Jeff
The 2 mentioned variables (
maxandclub) will be simply defined in a scope injected to directive’s controller. This means that you can write:in your directive’s controller.
If you want to read up more I would suggest the “Directive Definition Object” in the http://docs.angularjs.org/guide/directive where it talks about scopes in directives.