我正在编写一个简单的Flask Web应用程序,我试图在我的html页面上使用角度js显示一个简单的表格数据,我正在使用ng-repeat来循环数据,但它不能用于未知原因,当我检查控制台时,它没有显示任何错误。 请帮忙!
这是我的HTML代码
<tbody>
<!-- {% for user in User %}-->
<tr ng-repeat="user in User">
<td> // user.uid // </td>
<td >// user.taskname //
<input type="image" class="deleteImg" src="static/img/trash_can.png" height="15px" width="18px" name="removeId" value="{{user.uid}}" >
<input type="image" value="{{user.uid}}" src="static/img/editbtn.svg" height="15px" width="18px" name="editId">
</td>
</tr>
<!-- {% endfor %} -->
</tbody>
这是我的角度代码
<script>
var app = angular.module("app", []);
app.controller('myctrl', function($scope) {
$scope.myname="Howdy";
$scope.transfer= function(user) {
$scope.maintxt="kkk";
};
});
app.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('//').endSymbol('//');
});
</script>
答案 0 :(得分:1)
Flask Restful API:https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask
AngularJS正在使用Restful API:https://spring.io/guides/gs/consuming-rest-angularjs/
烧瓶中:
@app.route(path, methods=['GET'])
def get_User():
get list of user
if list of user is empty
return 404
return list of user as JSON
AngularJS:
controller $scope, $http
$scope.User = []
$http.get(APIEndPoint)
.then((response) => {
$scope.User = response.User
})
HTML:
<tr ng-repeat="user in User">
process user here
</tr>