Saturday, 15 March 2014

What to do with all those strings in angularjs -



What to do with all those strings in angularjs -

the lastly days started using angularjs , far.

but can't on strings have utilize create modules, controllers, well, everything.

class="lang-cs prettyprint-override">app = angular.module 'myapp', []

...

class="lang-cs prettyprint-override">angular.module('myapp').factory 'myservice', -> # service code

with strings, don't auto-completing help ide, , refactoring/renaming ugly find-replace-task.

currently, consider using sort of constant object polluting global namespace so

class="lang-cs prettyprint-override">appconstants = app_name: 'myapp' service_name: 'myservice'

and create modules etc. help of object

class="lang-cs prettyprint-override">app = angular.module appconstants.app_name, [] angular.module(appconstants.app_name).factory appconstants.service_name, -> # service code

but polluting global namespace seek avoid whenever possible. thought utilize amd or commonjs modules dependencies, have teach yeoman how ;)

i love hear think , it? ignore it? there angular way didn't stumble upon yet?

angularjs

No comments:

Post a Comment