Hi everyone !
Let’s consider 2 Angular modules, from 2 different OpenMRS modules:
openmrs-module-medicationmanagement
medication.js:
var medicationApp = angular.module('medication', [... ]);
openmrs-module-dispense
dispense.js:
var dispenseApp = angular.module('dispense', [... ]);
Let’s say the Medication angular module defines a custom directive named ‘order-summary’ to display any given order’s summary.
medication.js:
medicationApp.directive('orderSummary', function () {
return {
templateUrl: 'templates/order-summary-template.page'
};
})
templates/order-summary-template.gsp:
<div> <span>Order Summary</span> ... </div>
Now, I’d love to be able to use this directive in my Dispense page. dispense.gsp:
<div> <span>Dipense</span> <order-summary></order-summary> ... </div>
Problem is:
The directive in my page won’t work. It returns an empty directive. No error message anywhere.
But I’ve found that the problem is because the templateUrl page (templates/order-summary-template.page) from Medication module is not available when my Dispense page is loaded. Therefore the directive can’t be displayed.
Q: How to use an AngularJS custom directive with templateUrl from another module ?