简体   繁体   English

Angular JS对象与数组

[英]Angular JS Objects vs Array

I am trying to create an object with 3 properties inside. 我正在尝试创建一个具有3个属性的对象。 However, every time I run the code it will only display the code expression. 但是,每次我运行代码时,它只会显示代码表达式。 How do array and objects affect each other? 数组和对象如何相互影响?

My code: 我的代码:

 var app = angular.module("FundAllocation", []); app.controller("myCtrl", function($scope) { $scope.AllocFunds = [{Name:'Groceries',AllFunds:'2'}, {Name:'Travel',AllFunds:'2'}, {Name:'House',AllFunds:'2'} ]; }); 

 <div ng-app="app" ng-controller="myCtrl"> <div ng-repeat="row in AllocFunds"> row: {{row.Name} </div> </div>` 

You are missing the second curly brace in your HTML {{row.Name} . 您缺少HTML {{row.Name}的第二个花括号。 A missing curly brace won't display any errors and will just display what it literally is, in this case "{{row.Name}". 缺少的花括号将不会显示任何错误,而只会显示其字面意思,在这种情况下为“ {{row.Name}”。 The rest of your code seems fine and should work. 您的其余代码看起来不错,并且应该可以正常工作。

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

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