Friday, 15 January 2010

javascript - AngularJS : directives newbie -



javascript - AngularJS : directives newbie -

i'm starting great adventure angular , wanted inquire question regarding directives usage, not 100% sure after seeing multiple tutorials.

i want create simple app giving directions:

1) click button, fire in controller function current position navigator geolocation (i think no service necessary this, , can remain in controller?)

2) after getting coordinates have info place, should shown user, , here question: should there directive template binding these info scope , showing in dom, or plenty utilize "ng-hide" (which in fact directive - sic!:)) on div, fetch info on place service, bind hidden div, , set "ng-hide" false display dom containing place information.

the "ng-hide" variant seems easy, proper "angular way" or bad practice of beginners?

thank time , help in advance:)

imho

you can set in service if want utilize method different controllers or clean-code purpose. i utilize directives when want specific behaviour or grouping of controls repeat along application. if using basic html controls , need display/hide utilize ng-hide.

javascript angularjs angularjs-directive

No comments:

Post a Comment