Created
March 27, 2014 07:39
-
-
Save gabhi/9802312 to your computer and use it in GitHub Desktop.
Constants in angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this was driving me crazy a lot, read around 3 articles, and your solution works perfectly well =)