Comments (6)
Just use one IIFE, then all functions are in the same scope.
from angularjs-styleguide.
Indeed, that'd what you recommend in your README 😄
In fact I though about @johnpapa's styleguide where each file is wrapped with an IIFE.
I was more confident about collisions in the case you use variables out of the (main) function scope:
(function() {
var foo = 'bar';
function FooController() {
this.foo = foo;
}
angular
.module('app')
.controller('FooController', FooController);
})();
but finally I don't think this is a good practice (mostly for testing purpose)
from angularjs-styleguide.
Each file for me is an overkill, there isn't really need to and it gets a bit repetitive unless automated. Variables would be part of presentational logic if anything, therefore quite unique - just like the CSS we write, none of it should conflict with other parts of the app :)
If you've got 1000 JavaScript files, 999 extra function calls isn't necessary either!
from angularjs-styleguide.
Agreed with @toddmotto - I don't believe in bloating code with safeguards that would be avoidable using overhead-free best practices. A good variable naming convention could accomplish the same, in my opinion.
from angularjs-styleguide.
automation makes this easy to remove if you need to. and if this is the biggest problem your app has, then you are in great shape. :)
If you run locally in non automated mode (which a lot of devs do) the IIFE's give you a a truer sense of the global isolation than if you just avoid them.
I use a template/snippet, and there are no slowdowns.
Again, this is not a big deal as long as you do protect yourself in some way
from angularjs-styleguide.
Ok, interesting point of view. Indeed, it's not a big deal, and there is not a single way to manage scripts compilation.
Thanks for your answers
from angularjs-styleguide.
Related Issues (20)
- Yeoman generator for this style guide HOT 3
- Somekind of a new syntax with ng1.6 controllers.
- feature request: Advice on using Interface
- Missign injectable in directive with Classes
- Parent component trigger function in child component HOT 5
- Life without factories HOT 1
- Granularity of Modules HOT 1
- class constructors must be invoked with |new| HOT 1
- Wrong example in directive
- ng-annotate HOT 4
- index.js (index.ts) usage
- syntax error(s) in Typescript directive section for TodoAutoFocus as TS Class
- Register service with static constructor function? HOT 1
- calendar issues with table cell width with title column header
- Translating README to Spanish HOT 4
- Typescript Version: Which @types/angular version was used?
- reuse filters across components HOT 1
- Can't access form object in component's controller HOT 1
- Circular dependencies
- Spanish translation is old and don't match with current code.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angularjs-styleguide.