Reputation: 3
noob alert
This is weird - trying to create a custom directive in AngularJS, when I write this code:
myModule.directive('myTab', function(){
console.log('--Inside TAB directive--');
return
{
template: '<div>Hello World</div>'
};
});
It throws the exception: TypeError: Cannot read property 'compile' of undefined
However, this code runs fine:
myModule.directive('myTab', function(){
console.log('--Inside TAB directive--');
return {
template: '<div>Hello World</div>'
};
});
The only difference is the opening curly brace is on the next line in the first code. Is this behaviour normal?
Upvotes: 0
Views: 61
Reputation: 1309
because you are returning from the function and the next line is ignored. It will literally just see return, and return undefined
Upvotes: 1