Announcing Angular Kendo UI

In our first release of this year, we announced a new project at Kendo UI called "Labs". This is an incubator where we put all of the community contributions, as well as integrations with third party libraries. One of our most requested integrations has been for AngularJS.

Today, I am pleased to announce the official release of Angular Kendo UI. This is a complete set of directives for every widget in both the Web and DataViz suites. The goal was to provide deep integration with AngularJS while keeping Kendo UI's familiar declarative API. Angular Kendo UI is offered completely free and open under the Apache 2 license, and you can start using it in your Angular Projects today.

*Disclaimer*: While Angular Kendo UI is not supported under the formal Kendo UI support agreement, this is an active community project, and we would LOVE for you to open an issue, or fork the repo and submit a pull request. StackOverflow is also a great place to get assistance.

This project is brought to you by the Kendo UI Developer Relations team, and the tireless efforts of Pierre Asselin and Omkar Patil, who are members of the Labs Core Team. This project was not created for demos. It is not a proof of concept. It was largely influenced by Pierre and Omkar, who are doing development with Kendo UI and AngularJS right now, where they work, even as I write this article.

Up And Running

We structured the demo page so that you could quickly and easily wrap your mind around the way Kendo UI functions as a set of directives for AngularJS. If you aren't familiar with what AngularJS directives are, I wrote an article on ADC a few months ago that sums up the basics. Plainly stated, they are to AngularJS what declarative initialization is to Kendo UI. Let's look at an example.

If you were going to initialize an element with Kendo UI, you have two choices for how you do it. You can do it either imperatively, or declaratively.

There are strong opinions on both sides of the initialization debate. I don't want to stir the pot further, but allow me to propose that letting the markup define it's own function makes applications easier to maintain and scale. A phrase I use commonly is, "A div is not a calendar, a div is a div". It's difficult to tell what your markup's actual function is if the initialization is contained in a separate JavaScript file.

This is the idea of "compontizing" the web. Kendo UI has embraced this with declarative initialization, and AngularJS embraces it with directives. That being said, we have provided you with both methods of initialization to the best of our ability.

The Directive Direction

AngularJS glues the HTML to your JavaScript by way of controllers. While you can reference to the DOM from a controller, you shouldn't do that. Instead, AngularJS allows you to create something called a "directive". This is an isolated unit of code which is executed by AngularJS when it it's reference is found on an HTML element. Directives can be defined either as custom elements, attributes, comments, or classes. Some directives are quite simple, like ng-repeat.

ng-repeat Directive

This, or course, lists out all of the "things" defined in the array on the controller. It seems kind of like magic doesn't it?

Since you aren't supposed to initialize widgets from a controller, you need to have directives that will do it for you. I initially wrote the first pass at AngularJS directives for Kendo UI. The way that I did it was simply to call kendo.bind() and let you intialize all widgets with the same declarative initialization that you would normally use.

This works fine, and you can even specify a view model on the controller for data. The problem was that it just wasn't deeply integrated with AngularJS. It was essentially adding a second binding framework which was isolated from Angular's own. This meant that there was no way to tie widgets into Angular's binding and thus the full power of AngularJS could not be leveraged. The directive itself was really a very simple operation that simply called kendo.bind() on the current element and used the data-model attribute to define an MVVM observable on the controller.

A Complete Re-Write

Shortly after I published this first update, Pierre contacted me via email to make some suggestions about the integrations. Pierre and his team were using Kendo UI and AngularJS on a large project, and were dealing with integrating the two while in the trenches of real world development. Pierre quickly pointed out that we needed more integration with AngularJS, and took the first stab at re-writing the library. What transpired over the next several months was a complete re-write of Angular Kendo UI where we tied Kendo UI into AngularJS at a very fundamental level. Let's look at that same Kendo UI DropDownList as it works now.

The widget is specified with a dashed version of it's name - kendo-drop-down-list

Any configuration attributes are preceded with a k-

Anytime you have a configuration value that is not a primitive, you need to put single quotes around it. This is par for the course for AngularJS. We wanted to stay true to Angular, while at the same time staying as true to Kendo UI as we could. This is something that can trip you up, so Pierre added in a check that will shell out an error to your console if you forget the single quotes.

The widget can bind directly to an object on the scope. No need to wrap it in an observable

This means that you could grab the current value of the DropDownList and spit it back out using AngularJS template syntax.

This will of course display the currently selected item in the DropDownList in the div below it. You can see the tight integration between Kendo UI in AngularJS at work here. All you need to provide is the model that the DropDownList is bound to, and the binding is set.

Imperative Configuration In Controllers

I realize that not everyone agrees with me about putting all the configuration in the markup. On top of that, some configuration values are difficult to cite as attribute values due to the fact that you need to make sure that any objects are properly formed JSON. This can get tedious. For this reason, we allow you to specify your options on the controller, and pass them in to the k-options attribute.

Assigning Widget References

There are some occasions where you need to get a reference to a widget so that you can perform some sort of operation on it. A good example of this is the Kendo UI Window widget. It's likely that you will want to show the window on some certain event. You can assign a reference to the widget to a scope variable by passing the name directly into the widget directive itself.

This is a powerful tool in your arsenal, but use it responsibly. While you can still test your controllers, it's adviseable not to use widget references if you can avoid it.

A Complete UI Framework For AngularJS

We think that Kendo UI is the best choice for rich, fluid, and performant applications. We also think AngularJS provides a compelling end-to-end framework that changes the fundamental way we think about stitching all the pieces of a web application together. Together, you have an extremely powerful stack on which to build applications of considerable size and complexity.

We've worked very hard on this and are really thrilled to be able to release it. We look forward to seeing your feedback, issues, and of course pull requests! :)

Burke Holland

Burke Holland is a web developer living in Nashville, TN and was the Director of Developer Relations at Progress. He enjoys working with and meeting developers who are building mobile apps with jQuery / HTML5 and loves to hack on social API's. Burke worked for Progress as a Developer Advocate focusing on Kendo UI.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.