【发布时间】:2017-09-30 01:27:23
【问题描述】:
this is my html code.but the ngRepeat div show as commented in browser inspector
html ng-app="myApp">
<head>
<link rel="stylesheet" href="script/bootstrap.css">
<script src="script/tuto.js"></script>
<script type="text/javascript" src="script/angular.js"></script>
<script type="text/javascript" src="script/angular.min.js"></script>
<script type="text/javascript" src="script/bootstrap.js"></script>
<script type="text/javascript" src="script/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/app.css">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body style="padding: 50px" ng-controller="ctrl">
<div>
<p>
<input type="text" placeholder="Search..." ng-model="searchFor"
size="20" />
</p>
<div class="album panel panel-primary" ng-repeat="album in albums">
<div class="panel-heading">
{{ album.title }}
<div style="float: right">{{ album.date }}</div>
</div>
<div class="description">{{ album.description }}</div>
</div>
</div>
<p>
<input type="text" placeholder="Search..." ng-model="searchFor"
size="20" />
</p>
<div class="album panel panel-primary" ng-repeat="album in albums">
<div class="panel-heading">
{{ album.title }}
<div style="float: right">{{ album.date }}</div>
</div>
<div class="description">{{ album.description }}</div>
</div>
<h3>Add new Album</h3>
<div class="album panel panel-success" ng-repeat="album in albums">
<div class="panel-heading">
{{ album.title }}
<div style="float: right">{{ album.date }}</div>
</div>
<div class="description">{{ album.description }}</div>
</div>
</body>
</html>
enter code here
这是 HTML 代码。它也有 angularJs 的脚本部分。但是 ngRepaet div 显示为浏览器检查器中的注释
【问题讨论】:
-
你的 ng-app 在哪里?您应该在另一个文件中编写脚本并将其包含在 html
-
@ThanhTùng 我正在看一个教程..它是这样做的。之后我创建了单独的 js 文件并添加了 ng 应用程序..但结果相同
-
@ThanhTùng 检查我的新代码。我编辑了它。在另一个文件中编写脚本..但结果相同这是我的脚本文件代码 var myModal = angular.module('myApp', []); myModal.controller('ctrl', function($scope) { $scope.albums = [ { name: 'thailand1210', title: 'Surfing in Thailand', date: '2012-10-01', description: 'So hot !' }, { name: 'australia1207', title: 'Wedding in Australia', date: '2012-07-31', description: '这么多袋鼠和考拉!' } ]; $scope.addAlbum = function(new_album ) { $scope.albums.push(new_album); }; });
-
您的问题是您在 angular.js 上方包含文件脚本。包括以下内容,问题将得到解决
-
检查我的答案。如果问题解决了。请接受我的回答
标签: java html angularjs eclipse angularjs-ng-repeat