为什么没有元素的列表显示出来? [英] Why isn't list of elements showing up?

查看:139
本文介绍了为什么没有元素的列表显示出来?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个AngularJS 教程

I am working on an AngularJS tutorial

本教程介绍了NG-重复指令,一个AngularJS指令中使用重复的数据。

This tutorial covers the ng-repeat directive, an AngularJS directive used repeating data.

要显示NG重复的例子,笔者进入元素周期表的JSON格式,涵盖了元素的名称,元素#等成逻辑控制器($范围)

To show an example of ng-repeat, The author enters periodic table elements in a JSON format, covering element's name, element #, etc into controller logic($scope)

要显示的元素(code以下),笔者简单地用于一个HTML联合国有序列表指令

To display the elements(code below), the author simply used the directive with a html un-ordered list

<ul>
  <li data-ng-repeat="element in periodic.elements">{{element.name}} </li>
</ul>

我试图做同样的的jsfiddle 但元素的列表中没有显示出来,只有{{元素。名称}}

I tried doing the same JsFiddle but the list of elements isn't showing up, only {{element.name}}

起初我还以为这是一个AngularJS的语法问题,但我检查了scope属性,如果控制器名称相匹配,等等....我就确定启用的jsfiddle的AngularJS选项也是如此。

At first I thought this was an AngularJS syntax issue but I checked over the scope attribute, if the controller names match, etc.... I made sure to enable the AngularJS option in JsFiddle as well.

有谁知道问题是什么,或者为什么这个列表不显示出来?

Does anyone know what the issue is or why this list isn't showing up?

推荐答案

您忘了填写控制器语法来'});在code的端

You forget completing controller sytax '});' at the end of the code.

'use strict';
var chemistryApp = angular.module('chemistryApp', []);

chemistryApp.controller(
      'chemistryController',
    function chemistryController($scope) {
        $scope.periodic = {elements: [
            {
                "atomicNumber": 1,
                "name": "Hydrogen",
                "atomicWeight": 1.00794,
                "phase": "Gas",
                "ionization": 13.5984,
                "melting": -259.15,
                "boiling": -252.87
            },
            {
                "atomicNumber": 2,
                "name": "Helium",
                "atomicWeight": 4.002602,
                "phase": "Gas",
                "ionization": 24.5874,
                "melting": 0,
                "boiling": -268.93
            },
            {
                "atomicNumber": 3,
                "name": "Lithium",
                "atomicWeight": 6.941,
                "phase": "Solid",
                "ionization": 5.3917,
                "melting": 180.54,
                "boiling": 1342
            }
        ]
       };
    });

小提琴

这篇关于为什么没有元素的列表显示出来?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆