如何将角度js变量传递给javascript
我有一个显示弹性搜索数据的代码,目的是获取一些数据,计算平均值,并显示一个红色或绿色按钮 我才刚开始如何将角度js变量传递给javascript,javascript,angularjs,Javascript,Angularjs,我有一个显示弹性搜索数据的代码,目的是获取一些数据,计算平均值,并显示一个红色或绿色按钮 我才刚开始 <!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"&g
<!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(p1){
警报(p1);
}
仪表板
仪表板
外部服务
{{item[''u source']['tpsGecodage']}
添加TPSGEOCODAGE(项目[“来源”][“tpsGecodage]”);
该行上方^^^^应为ElasticSearch服务器上的测试搜索结果。
基本上,这个addTpsGeocodage(item[''u source']['tpsGecodage'])代码>(第29行)未执行任何操作
如何将变量从angular JS范围传递到javascript范围
谢谢将函数分配给变量,以便可以全局访问
<script type="text/javascript">
var addTpsGeocodage = function(p1) {
alert(p1);
}
</script>
var addTpsGeocodage=函数(p1){
警报(p1);
}
现在,您可以在任何地方访问addTpsGeocodage
。您想用该函数做什么?基本上,为什么要这样执行addTpsGeocodage?为什么不把函数放在控制器中?但是我可以在任何地方调用我的函数,只是javascript不能访问item[''u source']['tpsGecodage']的值,那么item[''u source']['tpsGecodage']应该是未定义的。{{item[''u source']['tpsGecodage']}的o/p是多少