I am trying to implement directive for dynamic template. Depending on what is selected in drop-down list, template should change. I only manage so far to implement to be dynamic on page load, but when value in drop-down list is changed, template stays the same..`(function () { 'use strict';
// directive for loading incomeinformation, regular or military
angular.module('myModule').directive('dynamicTemplate', templateControl);
templateControl.$inject = [];
function templateControl() {
var directive = {
controller: mycontroller,
controllerAs: 'mycontrollerCtrl',
bindToController: true,
restrict: 'E',
template: '<ng-include src="mycontrollerCtrl.getTemplateUrl()"/>'
};
return directive;
function mycontroller($attrs, $element, $scope, $compile) {
var vm = this;
vm.getTemplateUrl = getTemplateUrl;
function getTemplateUrl() {
if ($attrs.templateId == 1)
return "test1.html";
if ($attrs.templateId == 3)
return "test1.htm2";
return "test3.html";
}
}
}
})();`
And in html: <dynamic-template templateid="{{model.TemplateId}}"></imp-dynamic-template>