When To Use Worker And Factory Function In Angularjs
i am learning angularjs from Pro angularjs by adam freeman. This is an example he defined an directive in angularjs myApp.directive('highlight', function () { return function (sc
Solution 1:
If you take a look at the Angular docs about directives, you'll see that there are two ways you can define a directive. One is to use the directive definition object and the other is to just return a postLink function.
The example in your book shows the latter form. The reason your function doesn't work is because Angular calls your function and expects it to return a directive definition object or a postLink function. Instead the function you defined returns nothing or the result of element.css("color", "red")
depending on your if statement.
Post a Comment for "When To Use Worker And Factory Function In Angularjs"