I created a little test and it worked fine for me. I believe your issue is in your data and not in the approach shown here.
It seems is browser related as shows DOM manipulation. Is pointing to attributes. Maybe it doesn't like data-content attribute?
You could use ngSwitch too but it wouldn't be a dynamic template then.
Is this improving page loading at all? Why not use predefined sizes that can be stored and cached both on the client/server? It seems you are doing a lot of backend image processing which takes valuable server side time and resources. Besides dinamically generated images can't be cached by browser/web server unless you add dimensions to the url. Am I missing something?
@analog-nico after checking the gist everything looks fine. #1 and #2 are not really uses of "undefined" but a parameter using a JavaScript built-in object name which is not recommended but possible. You could also use parameters names like window, document or location with similar results.
Thanks for giving your opinion.
This protip is about the Module Pattern and not against AMD. AMD solves more complex scenarios. Please follow links for more information on AMD.
I see. That's what it seems to me. I did not invented the Module Pattern. You don't like it. It's fine. I believe is useful and backed up from many sources. I really don't understand why all this fuss. Use whatever you like. Even better add your own pro tip about it. These comments add no value and only makes everybody waste their time. Classic trolling in my book.
Why would I need to copy the code or replace it? It looks the same because is the SAME pattern. I'm sharing the code to help other developers. Best wishes. Have a lovely day.
You should stop trolling. Some other sources where you can see the very SAME pattern being used.
"Learning JavaScript Design Patterns", the Module Pattern, Addy Osmani 2014
These are examples of different notations for constructors.
@longlivechief maybe you could write your own pro tip on the topic?
@kfwerf Bind is not necessary. That is exactly what the first parameter does on call and apply. Just replace on my example Fn.call(this,2,3) or Fn.apply(this,[2,3]).
Code should be self explanatory. Only the last code makes use of a closure and fixes the initial problem. Anything else look the demo code. You don't need to agree.
AMD says it all async module definition. Is that what you want? You probably don't need it.
I recommend you reading Mozilla docs on closures. Private members are achieved by closures. Which is the base of encapsulation.
If you just want that you don't really need them.
Thanks for your comments. These libraries are not of my interest for what I wanted to show.
Scope isolation is related but not exactly the same concept as namespaces in JavaScript. I will write about JavaScript Modules and Sandboxing in another article.
Thanks! Included now.
Some will be surprised here. link
var stranger = 2;
var Order = (function() {
return function(id) {
this.id = id;
this.value = stranger;
stranger = 3;
}
})();
var order = new Order(1);
console.log(order.id); // 1
console.log(order.value); // 2
console.log(stranger); // 3
I see. I will write about JavaScript modularisation soon. As an example for a constructor is a little overkill though. Thanks!
Code shows really ugly compared to other state-of-the-art code visualisers. Any chance we will be able to integrate jsfiddle, jsbin like code snippets?
Bug. Your demo fails when you mark items as completed incrementing active items instead of completed.
How is the last link related to anything?
Only if you could... For the moment ES6 modules will be transpiled to ES5 using a similar approach. Look into the transpiled code and be shocked =)