Is AngularJS yet another library or it thoroughly has the capability to change the way we develop applications? What’s the difference between AngularJS and other libraries like the mature world wide known jQuery and its plethora of plugins, or Kendo UI /ExtJS? What brings it more in terms of data binding than KnockoutJS? This are the questions I will try to answer in order to decide if I would like to add AngularJS library to my skillset.
[fdropcap bg=”#333333″ color=”#ffffff”]F[/fdropcap]irst and foremost, it is supported by Google. I have great respect for the company and its products. Not to mention that they ship with extremely care and virtually no bugs, meaning that my task in fixing errors and unexpected behaviors would be easier.
[fdropcap bg=”#333333″ color=”#ffffff”]T[/fdropcap]he data-binding is natural: any controller and its properties are by default observable and the binding to HTML is by default two-way. Why would this be important? For example in KnockoutJS library one must always be sure that EACH subsequent property or method is created as observable, otherwise it won’t play nice and your beautifully designed HTML5/CSS3 view won’t show what you intend to. Or in Kendo UI, where you need only to specify the initial object as being observable, there are cases in which the “observable” wrapping is lost (during conversion to and from a JSON object). But with AngularJS, all objects are bindable, no mater if they are JSON-cloned.
[fdropcap bg=”#333333″ color=”#ffffff”]H[/fdropcap]uge DRY feeling – no more need for all the duplicated jQuery’s DOM queries in the case of updating rows in a grid – in which you find the element by class, get the desired attribute or property, compare it with the new value and replace it if necessary -in AngularJS’s case you declare the scope (in case of small apps is equal with the controller), bind desired property in HTML and run it! If the model gets updated, the binding automatically gets updated and new data is shown without you worrying about it! And the beauty of it is that with the same amount of code (hahaha) you get also the model updated from the HTML view if the property is bounded to a textbox’s value.
[fdropcap bg=”#333333″ color=”#ffffff”]B[/fdropcap]ecause the separation in Model View Controller, the controller can be easily tested in a controlled environment to find out if it works as intended. This also promotes the definition of a single concern in code, meaning that you’ll test just one feature and not a set of tight-coupled behaviors.