Reputation: 71
I am trying to build an angular app "the right way" using various style guides as my inspiration. John Papa's being the most notable. Most say I should wrap angular components in Immediately Invoked Function Expressions (IIFE) and separate them into different files. This works on everything except directives.
Am I doing something wrong or if I should not use IIFEs for directives or use them in a different way?
Here is my jfiddle of it not working: http://jsfiddle.net/HB7LU/14140/
Here is my jfiddle with it working without IIFEs: http://jsfiddle.net/8kfpf9aq/
The only difference is wrapping in:
(function() {
'use strict';
//code
});
I have tried it and it works similarly in several version of angular 1, 1.3, 1.4.
Upvotes: 0
Views: 329
Reputation: 5154
I think your problem might be that you're not invoking the IIFE. It should look like this
(function() {
'use strict';
//code
})();
or this
(function() {
'use strict';
//code
}).call(this);
Upvotes: 3