我正在編寫一個Angular應用程序,該應用程序與已在使用的Google AnalyticsAPI接口。 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>
'{{總[ 'GA:newVisits']}}' – dave