Skip to content

Instantly share code, notes, and snippets.

@gabhi
Created March 27, 2014 07:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabhi/9802312 to your computer and use it in GitHub Desktop.
Save gabhi/9802312 to your computer and use it in GitHub Desktop.
Constants in angular
//first in main controller
var myApp = angular.module('starter.controllers', []);
myApp.constant('mySettings', {
apiUri: '/api/foo',
nsUri: 'mySite/foo.xsd',
nsPrefix: 's'
});
//in the controller
angular.module('starter.controllers').controller('IndexCtrl',
function($scope, mySettings) {
$scope.consts = mySettings.apiUri;
});
@holms
Copy link

holms commented May 15, 2014

this was driving me crazy a lot, read around 3 articles, and your solution works perfectly well =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment