我正在本地的localhost:5000上使用flask运行它。如果我只是用浏览器打开html文件,它是有效的,但是在flask中不起作用。
我有一个名为"arr"的数组,在我的控制器中有4个数字。我想打印出每个数字,但ng-repeat不能这样做。真正有趣和关键的是,ng-repeat会重复n次,其中n为数组中项目的数量,所以这是好的,但它无法在ng-repeat ="number in arr"中打印变量{{number}} 。 这是我的代码:
这是浏览器中显示的内容:
<html ng-app='numberApp'>
<head>
<meta charset="utf-8">
<title>Cool</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script>
var numberApp = angular.module('numberApp', []);
numberApp.controller('numberCtrl', function($scope, $http){
$scope.arr = [2, 4, 5, 6];
});
</script>
</head>
<body ng-controller="numberCtrl">
<table>
<tr>
<th>First</th>
<th>Second</th>
<th>Third</th>
</tr>
<tr ng-repeat="number in arr">
<td> {{ 'start' }} </td>
<td> {{ number }} </td>
<td> {{ 'end' }} </td>
</tr>
</table>
</body>
</html>
这是浏览器中显示的内容:
First Second Third
start end
start end
start end
start end
它不会打印出{{ number }}。感谢任何能告诉我原因的人!