我有一个应用程序,我想在其中注入一个smartBanner元标记,但只在某些页面上。
在我的索引页面上,我有:
<!DOCTYPE html>
<html ng-app="ngBoilerplate" ng-controller="AppCtrl">
<head>
<title ng-bind="pageTitle"></title>
<!-- add smart banner to select pages through smartBanner directive -->
<smart-banner></smart-banner>
</head>
<body>
<ui-view></ui-view>
</body>
</html>我有一个指令:
angular.module('boh.components.smartBanner', [])
.directive('smartBanner', function(){
return {
restrict: "E",
template: '<meta name="apple-itunes-app" content="app-id=1080200000"></meta>',
replace: true
} ;
});我的问题是,我是否只是通过将指令注入到其他页面控制器中来调用该指令?
发布于 2016-04-27 10:52:04
我发现处理这个问题的最好方法是通过应用程序的PHP包装器。
我最终得到了这样的结果:
<?php
$urls = array("/app/explore", "/app/dashboard", "app/members", "/app/account-settings", "/app/jobs");
foreach ($urls as $key => $value) {
if( $_SERVER['REQUEST_URI'] === $value ) { ?>
<meta name="apple-itunes-app" content="app-id=########">
<?php }
}
?>https://stackoverflow.com/questions/36872237
复制相似问题