下面的html由於@符號而中斷。除了不使用@符號外,還有什麼解決辦法。我必須使用@符號,因爲json將在xml中使用newtonsoft jsonconvert http://www.newtonsoft.com/json在c#web api中生成。 jsonconvert在生成的json中用@符號前綴xml屬性。@符號破壞角度表達
如何解決@符號問題?有一件事對我來說是message.root.node1 [「@ attr1」]。如果可能,請提供一個資源,詳細說明在角度變量/表達式中禁止使用哪些符號。
<html ng-app="countryApp">
<head>
<meta charset="utf-8">
<title>Angular.js JSON Fetching Example</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script>
var countryApp = angular.module('countryApp', []);
countryApp.controller('CountryCtrl', function ($scope, $http) {
$scope.message = { "root": { "node1": { "@attr1": "1", "@attr2": "2" }, "node2": { "@attr1": "3", "@attr2": "4" } } }
});
</script>
</head>
<body ng-controller="CountryCtrl">
<h2>Angular.js JSON Fetching Example</h2>
<span>
menudatetime {{[email protected]}}
</span>
</body>
</html>
Google用@符號搜索任何東西都很麻煩。有什麼建議麼? –