gpt4 book ai didi

javascript - 无法让 ng-repeat 工作

转载 作者:行者123 更新时间:2023-11-28 17:57:29 25 4
gpt4 key购买 nike

我一直在练习 AngularJS 和 Angular Material。我遵循了使用 ng-repeat 的教程。我正在尝试自己做这件事,但我似乎无法让它发挥作用。我没有任何控制台错误。我不知道可能缺少什么,所以我可能缺少 Angular 中的一个重要概念。感谢您的帮助!

骗子:http://plnkr.co/edit/31WaRmH5RRdW5TFEFbg2

HTML

<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Angular Material</title>
<link rel="stylesheet" href="https://cdn.rawgit.com/angular/bower-material/v0.8.3/angular-material.css" />
<script src="https://code.angularjs.org/1.3.15/angular.js" data-semver="1.3.15"></script>
<script src="https://code.angularjs.org/1.3.15/angular-animate.js"></script>
<script src="https://code.angularjs.org/1.3.15/angular-aria.js"></script>
<script src="https://code.angularjs.org/1.3.15/angular-route.js"></script>
<script src="https://cdn.rawgit.com/angular/bower-material/v0.8.3/angular-material.js"></script>
<!-- ICON SET -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-material-icons/0.7.1/angular-material-icons.min.js"></script>

<script src="app.js"></script>
<script src="controllers.js"></script>

</head>

<body>

<md-list flex>

<md-item ng-repeat="artist in artists">
<a>
<md-item-content md-ink-ripple layout="row" layout-align="start center">
<div class="inset">{{ artist.name }}
</div>
</md-item-content>
</a>
</md-item>
</md-list>

</body>
</html>

app.js

var myApp = angular.module('myApp', [
'ngMaterial',
'ngRoute',
'ngMdIcons',
'artistControllers'
]);

controllers.js

var artistControllers = angular.module('artistControllers', []);

artistControllers.controller('ListController', ['$scope', '$http', function($scope, $http){
$http.get('data.json').success(function(data){
$scope.artists = data;
});
}]);

最佳答案

您错过了ng-controller包含在元素中。

<md-list flex ng-controller="ListController">

Plunker

关于javascript - 无法让 ng-repeat 工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44195873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com