Live data from Hacker News

Little-known directives of Angular.js

codetunes.com

21–24 of 24 posts

Re: Little-known directives of Angular.js

#21

Thanks for the post - I regularly use a lot of these, and I'm a big fan of ng-bind attribute over the {{ thing }} approach. Things that really caught my eye: - ng-list: sounds very useful for user forms, tagging, etc - ng-switch: I dont know how many times I've used ng-show to replicate this functionality. Thank you!

Just to be clear (and as mentioned in a comment on the post), ng-switch is actually closer in functionality to using multiple ng-if directives (which is only in Angular 1.1.5+). ng-switch actually adds/removes the elements from the DOM, whereas ng-show just shows/hides the element.

Re: Little-known directives of Angular.js

#23
post #16
post #4

ng-bind-html-unsafe has been removed in the latest release candidates, it won't be in 1.2 So try not to get attached.

Just use http://docs.angularjs.org/api/ng.$sce#methods_trustashtml on your data then use ng-bind-html. It does the same as ng-bind-html-unsafe.

Iterating over a collection in the controller and manually calling that on each element as needed is a huge pain.

Does it work in filters?

Re: Little-known directives of Angular.js

#24
post #21

Thanks for the post - I regularly use a lot of these, and I'm a big fan of ng-bind attribute over the {{ thing }} approach. Things that really caught my eye: - ng-list: sounds very useful for user forms, tagging, etc - ng-switch: I dont know how many times I've used ng-show to replicate this functionality. Thank you!

Just to be clear (and as mentioned in a comment on the post), ng-switch is actually closer in functionality to using multiple ng-if directives (which is only in Angular 1.1.5+). ng-switch actually adds/removes the elements from the DOM, whereas ng-show just shows/hides the element.

It also creates an additional scope whereas the ng:show does not.
Post reply on HN