My Angular code does not work when written as follows:
Here it is:
app.directive("strength", function() {
return
{
require: "superhero",
link: function(scope, element, attrs, superheroCtrl) {
superheroCtrl.addStrength();
}
}
})
However, when the return object's first curly bracket is on the same line as the return statement, the code works: Here's the code that works.
app.directive("strength", function() {
return {
require: "superhero",
link: function(scope, element, attrs, superheroCtrl) {
superheroCtrl.addStrength();
}
}
})
Am I doing something else incorrect?
How else can this be solved?
Thanks!
The return statement is affected by automatic semicolon insertion (ASI). There is no line terminator between the return keyword and the expression allowed.