Making global in angular js
http://angularjs.org/
by M. Junaid Salaat
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.2/angular.js"></script>
<div ng-controller="MyController">
Hello, {{role}}!
JS global var {{globVar}}
</div>
JavaScript
var globVar = 1233;
var myApp = angular.module('myApp', []);
myApp.service('GLOBALS', function() {
this.url = 'http://skindustries.dev/api/v1/';
this.role = 'oldRole',
this.companyid = '',
this.name = ''
});
myApp.controller('MyController', function(GLOBALS, $scope) {
$scope.globVar = globVar;
$scope.role = GLOBALS.role;
});