How do I Send Parameters from AngularJS To JS File?
I've been attempting to transfer data from Angular to an external JS File for quite some time now. I've tried using ng-model, ng-init, ng-bind and two-way directives without success.
<body lang="en" ng-app="app" ng-model="baseUrl='http://example.com'" >
<body lang="en" ng-app="app" ng-init=="baseUrl='http://example.com'" >
---- javascript
var app = angular.module('app', ['ui.grid','ui.grid.pagination']);
var baseUrl;
etc..etc..
All the information I come across regarding Angular Directives is about retrieving data from a JavaScript variable. However, I need to assign a value from Angular to a JS file instead.
The only solution I found so far is to use:
<script>
var global = {
baseUrl: 'http://example.com'
};
</script>
before declaring
<body lang="en" ng-app="app" ng-model="baseUrl='http://example.com'" >
in the HTML
Unfortunately, this approach doesn't work for me. Is there another workaround available? Any feedback would be greatly appreciated :)