我有一个元标记(苹果智能横幅),我想动态修改参数.但是它目前无法正常工作:
我假设在创建头之前调用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>
Run Code Online (Sandbox Code Playgroud)
部分:
<div data-ng-init="loadMe()" div class="col-md-12 passWindowDimensions">
Run Code Online (Sandbox Code Playgroud)
控制器:
/**
* Loading sequence. Loads the results
*/
$scope.loadMe = function(){
$scope.paramRId = 'test';
};
Run Code Online (Sandbox Code Playgroud)
尝试服务和指令
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;
};
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11462 次 |
| 最近记录: |