简体   繁体   English

ng-repeat在angularjs中不起作用

[英]ng-repeat not working in angularjs

Here is my code I can"t get the values , presently three values are present but values are not displaying: 这是我的代码,我无法获取值,目前存在三个值,但未显示值:

<body ng-controller="bucksbucket_orders">
    <form >
        <li ng-repeat="message in syncfromfbvalues">
            {{message.milk}},{{message.newspaper}},{{message.greens}}</li>
    </form>
</body>

Here is the values I try to get from firebase 这是我尝试从firebase获取的值

values
 |--->greens: "56"
 |===> milk: "56"
 |===>newspaper: "56"

My app.js 我的app.js

var fbvalues = new Firebase("https://qwertyuiop.firebaseio.com/values");

$scope.defaultfbvalues = function () {
    fbvalues.set({
        "newspaper": '56',
        "milk": '56',
        "greens": '56'
    });
};

$scope.syncfromfbvalues = $firebaseArray(fbvalues);

my plunker demo : http://embed.plnkr.co/acFOlruX0t4bCIxXohAF/preview 我的监听器演示: http ://embed.plnkr.co/acFOlruX0t4bCIxXohAF/preview

Change: 更改:

$scope.defaultfbvalues = function () {
     fbvalues.set({
          "newspaper": '56',
          "milk": '56',
          "greens": '56'
     });
};

To: 至:

$scope.defaultfbvalues = function () {
     fbvalues.set([{
          "newspaper": '56',
          "milk": '56',
          "greens": '56'
     }]);
};

The fbvalues is array "[ ]" fbvalues是数组“ []”

The AngularFire $firebaseArray is built to work with typical Firebase sequences, where the keys are in the form of -J-0FSHRJ913A and usually not displayed. AngularFire $firebaseArray firebaseArray构建为与典型的Firebase序列一起使用,其中键的格式为-J-0FSHRJ913A ,通常不会显示。

In your case, you'll want to display both the $id and $value : 对于您的情况,您需要同时显示$id$value

<li ng-repeat="message in syncfromfbvalues">
    {{message.$id}} - {{message.$value}}
</li>

Which displays: 显示:

  • greens - 56 果岭-56
  • milk - 56 牛奶-56
  • newspaper - 56 报纸-56

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

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