As I work on constructing a directive in angularJS, I come across an issue where I am attempting to bind an object property from another variable to an HTML element. Here is an example:
angular.module('ng.box', codeHive.angular.modules)
.directive('boxView', function($compile) {
return {
link: function(scope, element, attrs, ngModelCtrl) {
var name = 'exampl';
var htmlTemplate = '<div instance="'+scope[name].innerVal +'" </div> ';
var el = angular.element('<div/>');
el.append(htmlTemplate);
$compile(el)(scope);
element.append(el);
},
};
})
I am struggling to find a way to connect this object property to the instance attribute in the HTML element.
var htmlTemplate = '<div instance="'+scope[name].innerVal +'" </div> ';
If anyone has any suggestions or guidance on how to solve this problem, I would greatly appreciate it. Thank you!