3gwebtrain 3gwebtrain - 6 months ago 22
AngularJS Question

AngularJS directive not injecting & giving error

I am trying to inject a

directive
, but I am getting some error. Actually, I have declared the
modules
as the array, and pushing to the app, but still not working.

here is my code :

var appModules = ['app.directives', []]

var app = angular.module('plunker', appModules);


app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});


angular.module('app.directives', []).directive('myContent', function(){

return{

link:function(scope, element, attrs){

console.log("hi");

}

}

})


Live Demo

SSH SSH
Answer

change var appModules = ['app.directives', []] to var appModules = ['app.directives']