Skip to content

Commit

Permalink
feature: templateFile can now be changed on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Jan 25, 2016
1 parent 88fec67 commit 2f2c08f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 27 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.7",
"version": "1.0.8",
"homepage": "https://github.com/JohnnyTheTank/apiNG",
"authors": [
"Jonathan Hornung <[email protected]>"
Expand Down
34 changes: 22 additions & 12 deletions dist/aping.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
@name: aping
@version: 1.0.7 (25-01-2016)
@version: 1.0.8 (25-01-2016)
@author: Jonathan Hornung <[email protected]>
@url: https://github.com/JohnnyTheTank/apiNG
@license: MIT
Expand Down Expand Up @@ -39,26 +39,36 @@ angular.module('jtt_aping')
link: function (scope, element, attrs, controller, transcludeFn) {

var templatePath = scope.templateUrl;

scope.$watch('templateUrl', function () {
renderTemplate(scope.templateUrl);
});

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

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);
});
function renderTemplate(_templatePath) {
if (angular.isDefined(_templatePath) && _templatePath !== "$NONE") {
$templateRequest(_templatePath).then(function (html) {
var template = angular.element(html);
element.empty().append(template);
$compile(template)(scope);
});
} else {
transcludeFn(scope, function (clone, innerScope) {
element.append(clone);
$compile(clone)(innerScope);
});
}
}

},
controller: ['$scope', function ($scope) {

$scope.results = [];
$scope.payload = $scope.payloadJson ? apingUtilityHelper.replaceSingleQuotesAndParseJson($scope.payloadJson) : {};

Expand Down
Loading

0 comments on commit 2f2c08f

Please sign in to comment.