ng-meta
Advanced tools
Comparing version 0.3.7 to 0.3.8
{ | ||
"name": "ngMeta", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"authors": [ | ||
@@ -24,3 +24,6 @@ "Vinay Gopinath <vinayg18@gmail.com>" | ||
"test", | ||
"tests" | ||
"tests", | ||
"src", | ||
"Gruntfile.js", | ||
"CHANGELOG.md" | ||
], | ||
@@ -34,2 +37,2 @@ "dependencies": { | ||
} | ||
} | ||
} |
#Changelog | ||
## [v0.3.8](https://github.com/vinaygopinath/ngMeta/releases/tag/v0.3.8) | ||
##### Features | ||
* [#10](https://github.com/vinaygopinath/ngMeta/issues/10) `disableUpdate` option to disable $stateChangeSuccess updates for particular states (to be used in conjuction with state resolve functions) | ||
## [v0.3.7](https://github.com/vinaygopinath/ngMeta/releases/tag/v0.3.7) | ||
@@ -4,0 +10,0 @@ |
@@ -112,2 +112,6 @@ (function(root, factory) { | ||
if (meta.disableUpdate) { | ||
return false; | ||
} | ||
setTitle(meta.title, meta.titleSuffix); | ||
@@ -114,0 +118,0 @@ |
@@ -1,4 +0,4 @@ | ||
/* ngMeta - v0.3.7 - 24-Mar-2016 | ||
/* ngMeta - v0.3.8 - 24-Apr-2016 | ||
https://github.com/vinaygopinath/ngMeta | ||
*/ | ||
!function(a,b){"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?module.exports=b(require("angular")):a.returnExports=b(a.angular)}(this,function(a){a.module("ngMeta",[]).provider("ngMeta",function(){"use strict";function b(b){var e=function(e,f){if(!b.ngMeta)throw new Error("Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return b.ngMeta.title=a.isDefined(e)?e:c.title,d.useTitleSuffix&&(b.ngMeta.title+=a.isDefined(f)?f:c.titleSuffix),this},f=function(d,e){if(!b.ngMeta)throw new Error("Cannot call setTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");if("title"===d||"titleSuffix"===d)throw new Error("Attempt to set '"+d+"' through 'setTag': 'title' and 'titleSuffix' are reserved tag names. Please use 'ngMeta.setTitle' instead");return b.ngMeta[d]=a.isDefined(e)?e:c[d],this},g=function(b){b=b||{},e(b.title,b.titleSuffix);var d=a.copy(c);delete b.title,delete b.titleSuffix,delete d.title,delete d.titleSuffix;for(var g=Object.keys(b),h=0;h<g.length;h++)d.hasOwnProperty(g[h])&&delete d[g[h]],f(g[h],b[g[h]]);for(var i=Object.keys(d),j=0;j<i.length;j++)f(i[j],d[i[j]])},h=function(b,c){g(a.copy(c.meta))},i=function(){b.ngMeta={},b.$on("$routeChangeSuccess",h),b.$on("$stateChangeSuccess",h)};return{init:i,setTitle:e,setTag:f}}var c={},d={useTitleSuffix:!1};this.setDefaultTitle=function(a){return c.title=a,this},this.setDefaultTitleSuffix=function(a){return c.titleSuffix=a,this},this.setDefaultTag=function(a,b){return c[a]=b,this},this.useTitleSuffix=function(a){return d.useTitleSuffix=!!a,this},this.$get=["$rootScope",function(a){return new b(a)}]})}); | ||
!function(a,b){"function"==typeof define&&define.amd?define(["angular"],b):"object"==typeof exports?module.exports=b(require("angular")):a.returnExports=b(a.angular)}(this,function(a){a.module("ngMeta",[]).provider("ngMeta",function(){"use strict";function b(b){var e=function(e,f){if(!b.ngMeta)throw new Error("Cannot call setTitle when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");return b.ngMeta.title=a.isDefined(e)?e:c.title,d.useTitleSuffix&&(b.ngMeta.title+=a.isDefined(f)?f:c.titleSuffix),this},f=function(d,e){if(!b.ngMeta)throw new Error("Cannot call setTag when ngMeta is undefined. Did you forget to call ngMeta.init() in the run block? \nRefer: https://github.com/vinaygopinath/ngMeta#getting-started");if("title"===d||"titleSuffix"===d)throw new Error("Attempt to set '"+d+"' through 'setTag': 'title' and 'titleSuffix' are reserved tag names. Please use 'ngMeta.setTitle' instead");return b.ngMeta[d]=a.isDefined(e)?e:c[d],this},g=function(b){if(b=b||{},b.disableUpdate)return!1;e(b.title,b.titleSuffix);var d=a.copy(c);delete b.title,delete b.titleSuffix,delete d.title,delete d.titleSuffix;for(var g=Object.keys(b),h=0;h<g.length;h++)d.hasOwnProperty(g[h])&&delete d[g[h]],f(g[h],b[g[h]]);for(var i=Object.keys(d),j=0;j<i.length;j++)f(i[j],d[i[j]])},h=function(b,c){g(a.copy(c.meta))},i=function(){b.ngMeta={},b.$on("$routeChangeSuccess",h),b.$on("$stateChangeSuccess",h)};return{init:i,setTitle:e,setTag:f}}var c={},d={useTitleSuffix:!1};this.setDefaultTitle=function(a){return c.title=a,this},this.setDefaultTitleSuffix=function(a){return c.titleSuffix=a,this},this.setDefaultTag=function(a,b){return c[a]=b,this},this.useTitleSuffix=function(a){return d.useTitleSuffix=!!a,this},this.$get=["$rootScope",function(a){return new b(a)}]})}); |
{ | ||
"name": "ng-meta", | ||
"version": "0.3.7", | ||
"version": "0.3.8", | ||
"description": "Meta tags support for AngularJS single page applications (SPA)", | ||
@@ -50,2 +50,2 @@ "main": "src/ngMeta.js", | ||
} | ||
} | ||
} |
@@ -154,2 +154,20 @@ # ngMeta | ||
### Setting tags with custom data resolved by ui-router | ||
If you want to dynamically set your tags using ui-routers resolve (https://github.com/angular-ui/ui-router/wiki#resolve), this is possible as well: | ||
``` | ||
resolve: { | ||
data: function(..., ngMeta) { | ||
.... | ||
ngMeta.setTitle(); | ||
ngMeta.setTag('description', '....'); | ||
ngMeta.setTag('image', '....'); | ||
} | ||
}, | ||
meta: { | ||
disableUpdate: true | ||
} | ||
``` | ||
The property `disableUpdate: true` is required because ui-router will execute the resolve function *before* the $stateChangeSuccess event is fired. Setting `disableUpdate: true` will prevent your tags from getting reset by the $stateChangeSuccess event listener. | ||
## Support For Other Crawlers | ||
@@ -156,0 +174,0 @@ |
@@ -112,2 +112,6 @@ (function(root, factory) { | ||
if (meta.disableUpdate) { | ||
return false; | ||
} | ||
setTitle(meta.title, meta.titleSuffix); | ||
@@ -114,0 +118,0 @@ |
41329
758
202