Modules and namespace / name collision in AngularJS

As of today, AngularJS modules do not provide any sort of namespacing that would prevent collisions between objects in different modules. The reason is that an AngularJS app has a single injector that holds names for all objects without respect to module names. The AngularJS Developer Guide says: To manage the responsibility of dependency creation, …

Read more

Is there a way in AngularJS to define constants with other constants?

An easy way to do this is like this: var myApp = angular.module(“exampleApp”,[]); myApp.constant(‘RESOURCES’, (function() { // Define your variable var resource=”http://127.0.0.1:8008″; // Use the variable in your constants return { USERS_DOMAIN: resource, USERS_API: resource + “https://stackoverflow.com/users”, BASIC_INFO: resource + ‘/api/info’ } })()); And use the constants like this: myApp.controller(“ExampleCtrl”, function(RESOURCES){ $scope.domain = RESOURCES.USERS_DOMAIN; }); …

Read more

What is the difference between angular-route and angular-ui-router?

ui-router is a 3rd-party module and is very powerful. It supports everything the normal ngRoute can do as well as many extra functions. Here are some common reason ui-router is chosen over ngRoute: ui-router allows for nested views and multiple named views. This is very useful with larger app where you may have pages that …

Read more