diff --git a/dist/update-meta.js b/dist/update-meta.js index b0fe5a2..c26c2fa 100755 --- a/dist/update-meta.js +++ b/dist/update-meta.js @@ -14,7 +14,7 @@ angular.module('updateMeta', []); * * @constructor */ - function UpdateMetaDirective($log) { + function UpdateMetaDirective($log, $location) { function updateAttribute(selector, attributeName, attributeValue) { if(!document) { @@ -57,6 +57,9 @@ angular.module('updateMeta', []); if(scope.property) { selector = 'meta[property="' + scope.property + '"]'; + if (scope.property == 'og:url' && !scope.content){ + scope.content = $location.absUrl(); + } } if(scope.itemprop) { @@ -81,7 +84,7 @@ angular.module('updateMeta', []); } // Inject dependencies - UpdateMetaDirective.$inject = ['$log']; + UpdateMetaDirective.$inject = ['$log', '$location']; // Export angular diff --git a/dist/update-meta.min.js b/dist/update-meta.min.js index a0302ba..d99e3c7 100755 --- a/dist/update-meta.min.js +++ b/dist/update-meta.min.js @@ -1 +1 @@ -angular.module("updateMeta",[]),function(){function t(t){function e(e,n,r){if(!document)return t.error("updateMeta: document is not available!"),void 0;if(!e)return t.error('updateMeta: Either of "name", "httpEquiv", "property" or "charset" must be provided!'),void 0;var o=document.querySelector(e);o&&o.setAttribute&&o.setAttribute(n,r)}return{restrict:"E",scope:{charset:"@",name:"@",content:"@",httpEquiv:"@",scheme:"@",property:"@",itemprop:"@"},link:function(t){var n;t.name&&(n='meta[name="'+t.name+'"]'),t.httpEquiv&&(n='meta[http-equiv="'+t.httpEquiv+'"]'),t.property&&(n='meta[property="'+t.property+'"]'),t.itemprop&&(n='meta[itemprop="'+t.itemprop+'"]'),t.$watch("content",function(r){"undefined"!=typeof r&&e(n,"content",t.content)}),t.$watch("charset",function(n){"undefined"!=typeof n&&e("meta[charset]","charset",t.charset)})}}}t.$inject=["$log"],angular.module("updateMeta").directive("updateMeta",t)}(),function(){function t(){return{restrict:"E",scope:{title:"@"},link:function(t){t.$watch("title",function(t){"undefined"!=typeof t&&document&&(document.title=t)})}}}t.$inject=["$log"],angular.module("updateMeta").directive("updateTitle",t)}(); \ No newline at end of file +angular.module("updateMeta",[]),function(){function t(t,e){function n(e,n,r){if(!document)return t.error("updateMeta: document is not available!"),void 0;if(!e)return t.error('updateMeta: Either of "name", "httpEquiv", "property" or "charset" must be provided!'),void 0;var o=document.querySelector(e);o&&o.setAttribute&&o.setAttribute(n,r)}return{restrict:"E",scope:{charset:"@",name:"@",content:"@",httpEquiv:"@",scheme:"@",property:"@",itemprop:"@"},link:function(t){var r;t.name&&(r='meta[name="'+t.name+'"]'),t.httpEquiv&&(r='meta[http-equiv="'+t.httpEquiv+'"]'),t.property&&(r='meta[property="'+t.property+'"]',"og:url"!=t.property||t.content||(t.content=e.absUrl())),t.itemprop&&(r='meta[itemprop="'+t.itemprop+'"]'),t.$watch("content",function(e){"undefined"!=typeof e&&n(r,"content",t.content)}),t.$watch("charset",function(e){"undefined"!=typeof e&&n("meta[charset]","charset",t.charset)})}}}t.$inject=["$log","$location"],angular.module("updateMeta").directive("updateMeta",t)}(),function(){function t(){return{restrict:"E",scope:{title:"@"},link:function(t){t.$watch("title",function(t){"undefined"!=typeof t&&document&&(document.title=t)})}}}t.$inject=["$log"],angular.module("updateMeta").directive("updateTitle",t)}(); \ No newline at end of file diff --git a/src/updateMeta/directives/update-meta.directive.js b/src/updateMeta/directives/update-meta.directive.js index c4a300f..f35f77d 100644 --- a/src/updateMeta/directives/update-meta.directive.js +++ b/src/updateMeta/directives/update-meta.directive.js @@ -7,7 +7,7 @@ * * @constructor */ - function UpdateMetaDirective($log) { + function UpdateMetaDirective($log, $location) { function updateAttribute(selector, attributeName, attributeValue) { if(!document) { @@ -50,6 +50,9 @@ if(scope.property) { selector = 'meta[property="' + scope.property + '"]'; + if (scope.property == 'og:url' && !scope.content){ + scope.content = $location.absUrl(); + } } if(scope.itemprop) { @@ -74,7 +77,7 @@ } // Inject dependencies - UpdateMetaDirective.$inject = ['$log']; + UpdateMetaDirective.$inject = ['$log', '$location']; // Export angular