I have a controller (spring) that returns the version of the application (" version/get ") and I need to use this version to indicate the location of the js file:
<script src="/r/{{appVersion}}/js/app.js"></script>
How to do this using javascript or angularjs?
I tried to do something like this:
module.controller('ResourceLoaderController', [ '$rootScope', '$scope', '$http', function ($rootScope, $scope, $http) { 'use strict'; $scope.getVersion = function() { $http.get('/version/get').then(function (response) { $rootScope.appVer = response.data; }); }; $scope.getVersion(); }]);
And then:
<script src="js/controllers/ResourceLoaderController.js"></script> <div ng-controller="ResourceLoaderController"> <link rel="stylesheet" type="text/css" href="/r/{{appVer.text}}/css/app.css" charset="utf-8"> <script src="/r/{{appVer.text}}/js/app.js"></script> </div>
But I can not use the <div> in the header ...
source share