显示包含 Angular 的列表
Display a list with Angular
我有以下代码:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script type="text/javascript">
var application = angular.module('Application');
application.controller('ImageController', function ImageController($scope, $http) {
$scope.result = "Start here ...";
$http.get('api/images').
success(function (data, status, headers, config) {
$scope.images = data;
$scope.result = "Everything is ok";
}).
error(function (data, status, headers, config) {
$scope.result = "Something went wrong";
});
});
</script>
<div ng-app="Application" ng-controller="ImageControler">
<p>{{result}}</p>
<div ng-repeat='image in images'>
<span>{{image.votes}}</span>
</div>
</div>
我在呈现的 HTML 页面上得到的是 {{result}} 和 {{image.votes}} 就像 Angular 不工作...我还检查了 API 而且它不叫 ...
我错过了什么?
您在 <div ng-app="Application" ng-controller="ImageControler">
中有拼写错误
带 2 个 L 的控制器
我有以下代码:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script type="text/javascript">
var application = angular.module('Application');
application.controller('ImageController', function ImageController($scope, $http) {
$scope.result = "Start here ...";
$http.get('api/images').
success(function (data, status, headers, config) {
$scope.images = data;
$scope.result = "Everything is ok";
}).
error(function (data, status, headers, config) {
$scope.result = "Something went wrong";
});
});
</script>
<div ng-app="Application" ng-controller="ImageControler">
<p>{{result}}</p>
<div ng-repeat='image in images'>
<span>{{image.votes}}</span>
</div>
</div>
我在呈现的 HTML 页面上得到的是 {{result}} 和 {{image.votes}} 就像 Angular 不工作...我还检查了 API 而且它不叫 ...
我错过了什么?
您在 <div ng-app="Application" ng-controller="ImageControler">
带 2 个 L 的控制器