Lately, I've been struggling with implementing custom directives for my web application. Upon checking the JS console in Chrome, an error message pops up saying
Failed to instantiate module w2l-direc due to: {1}
. It appears that there may be an issue with the code within my module. As someone who is still new to Angular, any feedback regarding the code below would be greatly appreciated.
(function() {
var app = angular.module('w2l-directives', ['ui.bootstrap', 'ngRoute']);
app.directive('gamesCol',['$http', function($http){
return {
restrict: 'E',
templateUrl: 'games-col.html',
controller: function(){
this.games = $http.get('/js/games.json').success(function(data) {
this.games = data;
});
this.isSet = function(checkGame){
return this.game === checkGame;
};
this.setGame = function(activeGame){
this.game = activeGame;
};
},
controllerAs:'game'
};
}]);
app.directive('testimonyCol', function(){
return {
restrict: 'E',
templateUrl: 'testimonies-col.html',
controller: function(){
this.testimonials = $http.get('/js/testimonies.json').successs(function(data) {
this.testimonials = data;
});
this.current = 0
this.currentTestimony = testimonies[current];
this.setTestimony = function(checked){
if (checked !== this.currentTestimony) {
this.current = checked || 0;
}
};
},
controllerAs:'testimony'
};
});
})();`