我有這樣的代碼,我不知道爲什麼,但NG重複指令doesn't顯示結果被評論和doesn't顯示JSON對象的結果。我檢查,如果該對象被正確地傳遞到「this.paises2與toSource()方法,似乎一切都很好NG重複被評論和JSON對象
我在這裏檢查,但沒有任何工程。
AngularJS: ng-repeat not displaying JSON
ng-repeat code getting commented out when viewed from browser
ngRepeat div get commented out when i see from the browser inspector
下面是HTML代碼:
<html ng-app="miModulo">
<head>
<link href="mis-css.css" rel="stylesheet" type="text/css">
</head>
<body ng-controller="miControlador as vm">
<button ng-click="vm.buscarEnRegion()">Pulsar</button>
<ul ng-repeat="elemento in vm.paises">
<li>
{{elemento.name}}
</li>
</ul>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="mijs1.js"></script>
</body>
和JavaScript /角JS代碼:
angular
.module("miModulo",[])
.controller("miControlador",['$http',funcionPrincipal]);
function funcionPrincipal($http)
{
this.buscarEnRegion=function()
{
$http.get("https://restcountries.eu/rest/v1/region/africa").then(function(miRespuesta)
{
this.paises=miRespuesta;
// alert(miRespuesta.toSource());
alert(this.paises.toSource());
},function(miRespuesta)
{
alert("incorrecto");
}
); //then
}
}
在此先感謝。
您可以創建的jsfiddle?從UL –
變化NG-重複李 –