angularjs – angular ng-repeat不起作用

前端之家收集整理的这篇文章主要介绍了angularjs – angular ng-repeat不起作用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想运行一个小例子,但它不起作用.
HTML.

<body ng-app="angello">
<div ng-contoller="mainController">
  <div class="span4 sidebar-content">
    <h2> stories </h2>
      <div ng-repeat="story in stories">
        <h4> {{ story.title }} </h4>
        <p> {{ story.description }} </p>
      </div>
  </div>    
</div>

 

脚本代码是:

angular.module('angello',[])
         .controller('mainController',function( $scope ) {
      $scope.stories = [
        {title:'Story 00',description:'Description pending.'},{title:'Story 01',{title:'Story 02',{title:'Story 03',{title:'Story 04',{title:'Story 05',description:'Description pending.'}];
  });

预计会有故事被列出,但只有
{{story.title}}
{{story.description}}
标签.问题是什么?为什么这些故事没有列出?

小提琴:
http://jsfiddle.net/tire0011/gU7Qx/

解决方法

在您的HTML中,您拼错了ng-controller.你错过了一个r.当然,还要关闭身体标签.

修复ng-controller后,要使代码在jsFiddle中工作,你还必须更改框架上的onLoad&无包装的扩展 – 在< head>中正如@zeroFlagL所提到的那样.

猜你在找的Angularjs相关文章