【问题标题】:ngRepeat div get commented out when i see from the browser inspector当我从浏览器检查器中看到时,ngRepeat div 被注释掉
【发布时间】:2017-09-30 01:27:23
【问题描述】:

this is my html code.but the ngRepeat div show as commented in browser inspector

enter image description here

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


【解决方案1】:

您应该在另一个文件中编写脚本并添加ng-app 这是plnkr https://plnkr.co/edit/yvJGX52osH9eTJggexec?p=preview

您的问题是您在 angular.js 上方包含文件脚本。包括以下内容,问题将得到解决

    <link rel="stylesheet" href="script/bootstrap.css"> 
<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">
 <script src="script/tuto.js"></script> //include below

【讨论】:

  • 谢谢。它将解决问题..但现在 angulajs 无法正常工作..它显示为“{{专辑标题}}”。你的 plunker 例子也有同样的问题..你能建议任何答案吗
  • 可以为json文件添加img
【解决方案2】:

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-12-17
  • 2015-11-10
  • 1970-01-01
  • 2015-08-13
  • 2020-11-11
  • 2017-07-06
  • 2013-12-19
  • 2014-06-10
相关资源
最近更新 更多