i have a div having replace-with custom directive.
<div class="timeline" layout="row" ng-repeat="event in ::vm.events">
<div replace-with='{{event.content}}'></div>
</div>
This is my directive:
(function () {
'use strict';
angular
.module('app')
.directive('replaceWith', replaceWith);
/* @ngInject */
function replaceWith() {
// Usage:
//
// Creates:
//
var directive = {
link: link,
restrict: 'A'
};
return directive;
function link(scope, element, attrs) {
attrs.$observe('replaceWith', function (value) {
if (value) {
element.replaceWith(angular.isUndefined(value) ? '' : value);
}
});
}
}
})();
My Controller from where i am getting content data:
vm.templateUrl = "scripts/controllers/sample.content.html";
vm.events = [{
title: 'Title1',
subtitle: '',
date: '6/6/2016',
image: 'assets/avatar-5.png',
content: '<div ng-include="vm.templateUrl"></div>',
palette: ''
}]
Here my div with replace-with attribute is not getting replaced with ng-include template.but when i hard code my content data like content:<p>Sample Data</p>
it's working. can someone please help me with this.