Basically it is
<a ng:click="sort='id';reverse=!reverse" ng:class="sortIs('id')">Req
ID</a>
and
scope.sortIs = function(sortType) {
if (scope.sort == sortType) {
if (scope.reverse) {
return "currentSortReverse";
} else {
return "currentSort"
}
} else {
return "";
}
}
as well as adding the class definitions to the css.
Hope this helps.
Nate
On Dec 15, 10:39 pm, Dean Sofer <d...@jobvite.com> wrote:
> Hi there,
>
> I readhttp://docs.angularjs.org/#!/api/angular.Array.orderByand wanted to ask ….
>
> I have built this table example that uses sorting:http://jsfiddle.net/ProLoser/MS3TT/14/however I am trying to figure out an elegant way to change the class of each <th> to visually show that a: I'm sorting by that column and b: wether it's ascending or descending.
>
> How do I do that?
>
> ________________________________
>
> Dean Sofer | Software UI Engineer
> Jobvite, Inc.
> 270 East Lane | Suite 3 | Burlingame, CA 94010
> D...@jobvite.com<mailto:d...@jobvite.com> | 714.618.4641 (mobile)
> 650.376.7227 (office) | 650.648.0509 (fax)
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
--dan
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/_baYC9hk_-AJ.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/MP-p0T7eAf8J.
I believe declarative widgets (i.e. coded in angular html rather than
js) are coming in a later angular version (Misko hinted at this, and
it needs to be done for angular to scale to huge projects) but for now
the binding example is terse enough to work well.
I predict once that comes custom attributes will be deprecated.
Personally I'm lucky that I don't need/need declarative widgets for a
few months at least.
On Dec 16, 9:56 pm, Dan Doyon <dando...@yahoo.com> wrote:
> I'll give this a look to see what you're trying to accomplish. I can understand working for really clean modularized code. Widgets and directives can be (for me at least) a bit head spinning. If I were you, go for the simple and then refactor once you have proficiencies in the directive/widget arena. Have you looked at the angular-contrib project? It may give you some ideas (hopefully help more than harm) and there are some utils that the developer created there.
>
> --dan
>
> On Dec 16, 2011, at 5:23 PM, ProLoser wrote:
>
>
>
>
>
>
>
> > I'm trying to work with your cleaned up version and attempted to create a directive that makes bundles both the visual and programmatic behaviors together:
>
> >http://jsfiddle.net/js64b/11/
>
> > However no matter what I try I cannot get it to work. I am really frustrated that I can't seem to use widgets or directives to make life bundle up functionality. I have to explicitly do everything.
>
> > --
> > You received this message because you are subscribed to the Google Groups "AngularJS" group.
> > To view this discussion on the web visithttps://groups.google.com/d/msg/angular/-/MP-p0T7eAf8J.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/LtSk-8G8i7AJ.
Dean,
The heading is not rendering and I believe that it has to do with the fact that ng: repeat is an attribute widget and you’ve declared ui:sort as an attribute widget.
Per the doc, “Only one attribute widget is allowed per element.”, this is why I went with a regular widget.
http://docs-next.angularjs.org/guide/dev_guide.compiler.widgets
So I changed your ui:sort to a directive. I also made things ‘less verbose’. I made it verbose intentionally, however, this refactored version reads pretty well.
http://jsfiddle.net/dandoyon/SfaKu/
I agree with Vojta on using angular built-ins such as ‘ng:click’. But I also agree that having the techniques in place for creating directives/widgets is a good thing.
--dan
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/fDjOAxJJOowJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2012.0.1901 / Virus Database: 2109/4713 - Release Date: 12/30/11