Sunday, March 17, 2013

Filters & some Useful Links


I noticed a neat trick in the comments for $filter, pointing out a more intuitive way to use a filter in your code than the example syntax where you import '$filter' into your directive, and then use:
newArray=$filter('orderBy')(myArray,'sortKey');


If you want to use a filter, you don't need to import the $filter service, just import the filter you want by appending 'filter' to the end of the filter you want. So if you have a filter called, "myAwesome", you would import "myAwesomeFilter"

Importing the date filter into your directive would look like this:
  .directive('myCurrentTime', function($timeout, dateFilter) {
and to use it inside of your directive you can now simply access the filter by name:
        element.text(dateFilter(new Date(), format))
See this fiddle for an example.

IN OTHER NEWS...

Also, check http://ngmodules.org/ for updates before writing your own widget.
...and, it turns out there is a Google Group dedicated to AngularUI, with a Bootstrap-UI specific sub-Group.

No comments:

Post a Comment