首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ng-repeat属性不起作用。我正在使用angularJs,但ng-repeat不起作用。以下是我的代码

ng-repeat属性不起作用。我正在使用angularJs,但ng-repeat不起作用。以下是我的代码
EN

Stack Overflow用户
提问于 2016-08-28 00:18:00
回答 1查看 47关注 0票数 0
代码语言:javascript
复制
<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>

我想使用ng-repeat和ng-controller在我的页面上以媒体格式显示很多项目。这是我写的代码。但是,每当我运行它时,都没有任何东西出现在它的位置上。内容(理想情况下应该是已支付的内容)在变为空白之前闪烁了大约半秒钟。我看到的只是一张白纸。请告诉我我的代码哪里错了!毫无线索。

EN

回答 1

Stack Overflow用户

发布于 2016-08-28 00:32:15

您的应用程序中存在一些错误。请参考这个柱塞。这是您的代码中的一个完整的工作示例。此外,也没有ng-app指令

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

代码语言:javascript
复制
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"
      }];

    }]);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39183220

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档