Hi,
Following
this guide, I'm trying to get context path using AngularJS. Based on that context path, I include a JS file that contains JQuery scripts.
The problem is the JS file has been included but the script doesn't run. I wonder if the merging of AngularJS and JS caused the problem.
1) Can I use JQuery $.ajax() to get the context path? If so, what's the rest engine URI should I pass? How can I do it if I don't have a context path to prepend it to "engine-rest/engine/default/task/.../form"?
2) Do every pages must include this script to get context path before including <script>, <link> or <img>? Is there a way to reuse it?
test.html
<form role="form" class="form-horizontal">
<script cam-script type="text/form-script">
inject(['$http', 'Uri', function($http, Uri) {
camForm.on('form-loaded', function() {
$http.get(Uri.appUri("engine://engine/:engine/task/" + camForm.taskId + "/form")).success(function(result){
$scope.contextPath = result.contextPath;
});
});
}]);
$scope.getPath = function (path) {
return $scope.contextPath + path;
};
</script>
<script type="text/javascript" ng-src="{{getPath('/resources/js/my-app/test.js')}}"></script>
</form> Inspect Element, it gives
<script type="text/javascript" ng-src="/my-app/resources/js/test.js" src="/my-app/resources/js/test.js"></script>
test.js
Tags: embedded form, Camunda 7.2 JBoss distribution, AngularJS, JQuery.
Thank you and Merry Christmas,
Emerald Hieu