Skip to content

Commit

Permalink
fix: innerHtml templates will get rendered now. thanks to manuelrauber
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Jan 24, 2016
1 parent 6758ed5 commit 69ffcb5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apiNG",
"version": "1.0.5",
"version": "1.0.6",
"homepage": "https://github.com/JohnnyTheTank/apiNG",
"authors": [
"Jonathan Hornung <[email protected]>"
Expand Down
31 changes: 28 additions & 3 deletions dist/aping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@name: aping
@version: 1.0.5 (24-01-2016)
@version: 1.0.6 (24-01-2016)
@author: Jonathan Hornung <[email protected]>
@url: https://github.com/JohnnyTheTank/apiNG
@license: MIT
Expand All @@ -22,7 +22,8 @@ angular.module('jtt_aping')
.directive('aping', ['apingResults', 'apingDefaultSettings', 'apingUtilityHelper', '$templateRequest', '$compile', function (apingResults, apingDefaultSettings, apingUtilityHelper, $templateRequest, $compile) {
return {
restrict: 'E',
replace: 'false',
transclude: true,
template: '<ng-transclude></ng-transclude>',
scope: {
model: '@',
getNativeData: '@',
Expand All @@ -35,6 +36,30 @@ angular.module('jtt_aping')
removeDoubles: '@',
valueName: '@'
},
link: function (scope, element, attrs, controller, transcludeFn) {

var templatePath = scope.templateUrl;
if (angular.isUndefined(templatePath)) {
if (angular.isDefined(apingDefaultSettings.templateUrl)) {
templatePath = apingDefaultSettings.templateUrl;
}
}

if (angular.isDefined(templatePath) && templatePath !== "$NONE") {
$templateRequest(templatePath).then(function (html) {
var template = angular.element(html);
element.append(template);
$compile(template)(scope);
});
} else {
transcludeFn(scope, function (clone, innerScope) {
element.append(clone);
$compile(clone)(innerScope);
});
}
},
/*
link: function (scope, element, attrs) {
var templatePath = scope.templateUrl || undefined;
Expand All @@ -58,7 +83,7 @@ angular.module('jtt_aping')
element.html(html);
$compile(element.contents())(scope);
}
},
},*/
controller: ['$scope', function ($scope) {
$scope.results = [];
$scope.payload = $scope.payloadJson ? apingUtilityHelper.replaceSingleQuotesAndParseJson($scope.payloadJson) : {};
Expand Down
Loading

0 comments on commit 69ffcb5

Please sign in to comment.