[英]how to pass a angular-js variable to javascript
所以我有这段代码来显示弹性搜索的数据,目的是获取一些数据,计算平均值并显示红色或绿色按钮。
我才刚开始
<!doctype html>
<html ng-app="EsConnector">
<link rel="stylesheet" href="styles/main.css">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.js"></script><!-- // a recuperer -->
<script src="scripts/controllers/elasticsearch.angular.js"></script>
<script src="scripts/controllers/es_connect.js"></script>
</head>
<script type="text/javascript">
function addTpsGeocodage(p1) {
alert(p1);
}
</script>
<body>
<title>Dashboard</title>
<h1 align="center">Dashboard </h1>
<hr>
<h3>Services Externes</h3>
<div ng-controller="QueryController">
<div >
<table>
<tr ng-repeat="item in hits">
<td>
{{item['_source']['tpsGecodage']}}
<script>
addTpsGeocodage(item['_source']['tpsGecodage']);
</script>
<span class="green_circle" ng-if="item['_source']['tpsGecodage'] < 1">
<a href="kibana link">Lien </a>
</span>
</td>
</tr>
</table>
</div>
</div>
<br>
Above this line ^^^ should be the results of a test search on the ElasticSearch server.
</body>
</html>
基本上,此addTpsGeocodage(item['_source']['tpsGecodage']);
(第29行)什么也不做。
如何将变量从有角JS范围传递到javascript范围。
谢谢
将函数分配给变量,以便可以全局访问它。
<script type="text/javascript">
var addTpsGeocodage = function(p1) {
alert(p1);
}
</script>
现在,您可以在任何地方访问addTpsGeocodage
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.