I am drawing a total blank after trying without success to use an external
template file in a directive.
I am using angular 1.3.14 on nodejs with express ejs framework.
I have the following directive working well (still need to add checks and
balances) but want to use a template url to file instead of embedding the
file in the directive.
You'll see in confirmModal I am adding 'runVar' dynamically to string that
is returned as template. This variable is provided by including attribute
'data-run' as below.
<div data-bs-confirm class="modal fade" role="dialog" id="runRecipe"
data-run="startProgram(program.select.name, power.power.value)">
</div>
I'd like to rather use templateUrl and somehow pass in 'runVar' and have
the template file processed.
appDirectives.directive('bsConfirm', function(){
var confirmModal = function(runVar) {
return '<div class="modal-dialog modal-sm">'+
'<div class="modal-content">'+
'<div class="modal-header">'+
'<button type="button" class="close"
data-dismiss="modal">×</button>'+
'<h4 class="modal-title">Confirm</h4>'+
'</div>'+
'<div class="modal-body">'+
'<p>Run Recipe?</p>'+
'</div>'+
'<div class="modal-footer">'+
'<button type="button" class="btn btn-default"
data-dismiss="modal">No</button>'+
'<button id="confirm"type="button"class="btn
btn-default"data-dismiss="modal" ng-click="'+runVar+'">Yes</button>'+
'</div>'+
'</div>'+
'</div>';
}
return {
restrict: 'AE',
template: function(elem, attrs) {
var run=attrs['run'];
return confirmModal(run); //how would I compile templateUrl passing
in 'run' variable?
},
link: function(scope, elem, attrs) {
elem.removeAttr('data-run');
}
}
});
Appreciate any ideas - note I am trying to avoid creating more controllers.
~Colin
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.