简体   繁体   English

ng-repeat属性不起作用。 我正在使用angularJs,但是ng-repeat无法正常工作。 这是我的代码

[英]ng-repeat attribute not working. I am using angularJs but the ng-repeat is not working. Here is my code

<div class="container">
    <div class="row" style="padding-top:50px" ng-controller="projects_control">
        <div class="col-md-12">
            <ul class="media-list">
                <li class="media" ng-repeat="project in projects">
                    <div class="media-left media-middle">
                        <a href="#"><img ng-src="{{project.image}}"></a>
                    </div>
                    <div class="media-body">
                        <h2 class="media-heading">{{project.name}} <span class="label label-danger label-xs">{{project.status}}</span>
                        </h2>
                        <p>{{project.short_description}}</p>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>

<script src="angular.min.js"></script>
<script>
var app = angular.module("mmproapp",[]);
app.controller=("projects_control", ["$scope", function($scope){
$scope.projects=[{
    image:"Aliens.jpg",
    name:"Quadcopter",
    status:"Currently under work",
    short_description:"This would be a short description about the project that would have atleast 5-6 lines explaining in short about the main goal of the project along with the major difficulty or something like that. Just to fill this description box.",
    long_description:"HCHCKGKJ>LGHCB>KLKYFIUKUJC"
},
{
    image:"daily_tasks.jpg",
    name:"Something",
    status:"Finished",
    short_description:"kmsegadkuyag;klusdglujwecliwe This would be a short description about the project that would have atleast 5-6 lines explaining in short about the main goal of the project along with the major difficulty or something like that. Just to fill this description box.",
    long_description:"HCHCKGKJ>LGHCB>KLKYFIUKUJC"
}];
}]);
</script>

I want to use the ng-repeat along with ng-controller to display a lot of projects on my page, in a media format. 我想将ng-repeat和ng-controller一起使用,以媒体格式在页面上显示很多项目。 This is the code i wrote. 这是我写的代码。 However, whenever I run it, nothing appears at all in its place. 但是,每当我运行它时,什么都不会出现。 The content (what should have been ideally dispayed) flashes for about half a second before going blank. 内容(理想情况下应该偿还的金额)闪烁约半秒钟,然后变为空白。 All i see is a blank page. 我所看到的只是一个空白页。 Kindly tell me where my code is wrong! 请告诉我我的代码在哪里错误! I have no clue. 我没有任何线索。

There are some errors in your application. 您的应用程序中存在一些错误。 Please refer to this plunker. 请参阅此插件。 It is a full working example from your code. 这是您代码中的完整示例。 Also there is no ng-app directive 也没有ng-app指令

https://plnkr.co/edit/0FZVMoPkMyLUJh4dsRdf?p=preview https://plnkr.co/edit/0FZVMoPkMyLUJh4dsRdf?p=preview

var app = angular.module("mmproapp", []);

app.controller("projects_control", ["$scope", function($scope) {

      $scope.projects = [{
        image: "Aliens.jpg",
        name: "Quadcopter",
        status: "Currently under work",
        short_description: "This would be a short description about the project that would have atleast 5-6 lines explaining in short about the main goal of the project along with the major difficulty or something like that. Just to fill this description box.",
        long_description: "HCHCKGKJ>LGHCB>KLKYFIUKUJC"
      }, {
        image: "daily_tasks.jpg",
        name: "Something",
        status: "Finished",
        short_description: "kmsegadkuyag;klusdglujwecliwe This would be a short description about the project that would have atleast 5-6 lines explaining in short about the main goal of the project along with the major difficulty or something like that. Just to fill this description box.",
        long_description: "HCHCKGKJ>LGHCB>KLKYFIUKUJC"
      }];

    }]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM