Last Updated: February 25, 2016
·
946
· nicktea

Keeping your global namespace clean #CoffeeScript #Angular

Pro Tip for keeping you global namespace clean using Angular and CoffeeScript:

app.coffee

@YourApp = angular.module("YourApp", ['mobile-navigate', 'ui', 'ngCookies', 'ngResource', '   filters', 'ngUpload']) 
.config(["$routeProvider", ($routeProvider) -> 

Then you easily access one global variable from your controllers etc ...

main.coffee

YourApp.controller 'MainCtrl', 
'$scope', '$route', '$location', 'CurrentUser', '$cookies', 'TokenHandler', '$http', 
($scope, $route, $location, CurrentUser, $cookies, TokenHandler, $http) ->

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

Angular apps often share the page with analytics and payment scripts that are not Angular modules. Those scripts execute on the same origin as the framework.

Security insights from Cside