我有一个元标记(苹果智能横幅),我想动态修改参数.但它目前无法正常工作:
我假设在创建头之前调用ng-init?如果是这样,我可以通过加载方法修改元数据?
这是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>
部分:
<div data-ng-init="loadMe()" div class="col-md-12 passWindowDimensions">
控制器:
/** * Loading sequence. Loads the results */ $scope.loadMe = function(){ $scope.paramRId = 'test'; };
尝试服务和指令
原文链接:/angularjs/143835.htmlmodule.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; }; });