Let me show you how to add angular controller dynamically: after application has bootstrapped.
It is useful for example when you are loading components dynamically.
Yesterday at work, I’ve received a task, which I should had done today (and I actually did). Simple task to filter table by logical value in one column.
So I had 3 values to filter by: null, true and false(not filtered, published, unpublished).
I’ve thought what would be the best visual solution for that…
I knew, that I don’t want to create three-option select, like that:
(what is actually the fastest solution of that issue) .
But I’ve decided to make three-state checkbox. I wanted it to be clean and semantic solution,
so I’ve also decided to create open-source package with AngularJS directory of three-state-checkbox.
Image above clearly shows how does scope is nesting in JavaScript.
In JavaScript ECMAScript 5 every scope it is a scope of function. Blocks, like if{}else{}, are not creating their own scope.
If you want to make your function block-scoped in ES5 you’ll have to nest it to another function.
But in ECMAScript 6 you have better solution!