allow templates as functions and string for unContent directive

This commit is contained in:
2019-10-22 11:36:50 +02:00
parent e295913403
commit d263caba29
2 changed files with 21 additions and 17 deletions
@@ -594,16 +594,14 @@ un-config
.unesting-picker input.search-query
{
font-weight: 400;
font-size: 14px;
border-color: transparent;
border-radius: 18px;
height: 40px;
padding-top: 6px;
box-shadow: 0 1px 1px 0 rgba(0,0,0,.10);
background: #faf8f8;
}
.unesting-picker input.search-query:focus
{
border-color: transparent;
}
.unesting-picker .form-search .icon-search
{
top: 10px;
@@ -5,9 +5,10 @@ angular.module('umbraco.directives').directive('unContent', function ($compile)
return {
restrict: 'E',
scope: {
item: '=',
node: '=',
config: '='
item: '<',
node: '<',
config: '<',
template: '<'
},
link: function (scope, element)
{
@@ -15,6 +16,18 @@ angular.module('umbraco.directives').directive('unContent', function ($compile)
// get template
var template = scope.config && scope.config.nameTemplate ? scope.config.nameTemplate : null;
if (scope.template)
{
if (typeof scope.template === 'function')
{
template = scope.template();
}
else if (typeof scope.template === 'string')
{
template = scope.template;
}
}
// compile & render template
function render()
{
@@ -34,13 +47,6 @@ angular.module('umbraco.directives').directive('unContent', function ($compile)
$compile(element.contents())(scope);
}
//var unsubscribe = scope.$on("ncSyncVal", function (ev, args)
//{
// if (args.key === scope.node.key)
// {
// render();
// }
//});
var unsubscribe = scope.$watch('item', function (value)
{
render();