I have a meta tag (apple smart banner) and I want to modify the argument on the fly. However it is currently not working:
I assume the ng-init is called before the head is created? If so, I can modify the meta through a load method?
here is the html:
<!doctype html>
<html lang="en" ng-app="myApp" class="passWindowDimensions">
<head>
<meta charset="utf-8">
<title>XXXXXX</title>
<link rel="stylesheet" href="css/app.css"/>
<link rel="stylesheet" href="css/bootstrap.css"/>
<meta name="apple-itunes-app" content="app-id=XXXXXXX, app-argument = {{paramRId}}">
<!--Let search engines know we are a single page ajax app-->
<meta name="fragment" content="!">
<script src="js/JQuery.js"></script>
<script src="js/searchFunctions.js"></script>
</head>
Partial:
<div data-ng-init="loadMe()" div class="col-md-12 passWindowDimensions">
Controller:
/**
* Loading sequence. Loads the results
*/
$scope.loadMe = function(){
$scope.paramRId = 'test';
};
The Angular Meta Service makes it easier to set different meta tags to different pages. It provides methods such as addTag() , addTags() , getTag() , getTags() , updateTag() , removeTag() , removeTagElement() etc. We can use them to manipulate meta tags. Let us find out how to use Meta service using an example.
Meta Tags in Route Add the Meta Tags property in route data. We can use the Route data to pass the static data or dynamic data to routed components.
Try a service and a directive
http://jsfiddle.net/VnXYB/
module.factory("smartBanner", function() {
return {
appId: "",
appArgument: ""
}
});
module.directive("smartBanner",function(smartBanner){
return {
restrict: "E",
template: '<meta name="apple-itunes-app" content="app-id={{smartbanner.appId}}, app-argument = {{smartbanner.appArgument}}"></meta>',
replace: true,
link: function(scope) {
scope.smartbanner = smartBanner
}
}
});
module.controller("TestCtrl", function($scope,smartBanner){
$scope.update = function() {
smartBanner.appId=$scope.appId;
smartBanner.appArgument=$scope.appArgument;
};
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With