【发布时间】:2014-01-10 23:02:24
【问题描述】:
我正在编写一个 Angular 应用程序,该应用程序与已在使用的 Google Analytics API 交互。 Google 返回的数据以“ga:”为前缀,如示例“ga:newVisits”。
如果我使用表达式 {{total.ga:newVisits}},Angular 无法解析它。任何试图转义冒号以继续的尝试都导致了错误或完全转义了我的表达。
如何将 {{total.ga:newVisits}} 传递给 Angular 以使表达式正常工作?
<!doctype html>
<html ng-app="AnalyticsApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
<script src="angular-controller.js"></script>
</head>
<body ng-controller="AnalyticsCtrl">
<ul>
<li ng-repeat="total in result">
{{total.ga:newVisits}}
</li>
</ul>
</body>
</html>
【问题讨论】:
-
{{total['ga:newVisits']}}
标签: javascript regex angularjs google-analytics