久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

angular.js - items.query is not a function這是怎么回事

瀏覽:224日期:2024-10-05 18:26:13

問(wèn)題描述

<p ng-app='myApp'> <p ng-controller='firstcontroller'><h1>Shop!</h1><table> <tr ng-repeat='item in items'></tr> <td>{{item.title}}</td> <td>{{item.description}}</td> <td>{{item.price | currency}}</td> </tr></table> </p></p> <script>var app = angular.module('myApp', []);app.factory(’items’, function() { var items = {}; items.query = function() {return [{ title: ’Paint pots’, description: ’Pots full of paint’, price: 3.95}, { title: ’Polka dots’, description: ’Dots with polka’, price: 2.95}, { title: ’Pebbles’, description: ’Just little rocks’, price: 6.95}]; } return items;})app.controller(’firstcontroller’,[’$scope’,’items’,function($scope,items){ $scope.items=items.query();}])</script>

瀏覽可以正確運(yùn)行代碼,但是不顯示數(shù)據(jù)。只顯示出angular.js -  items.query is not a function這是怎么回事

<p ng-app='myApp'> <p ng-controller='firstcontroller'><h1>Shop!</h1>{{items}} </p></p>

代碼更改成這樣,可以顯示出數(shù)據(jù),說(shuō)明數(shù)據(jù)已經(jīng)綁定成功了,為什么使用這段代碼,無(wú)法顯示數(shù)據(jù)?

<table> <tr ng-repeat='item in items'></tr> <td>{{item.title}}</td> <td>{{item.description}}</td> <td>{{item.price | currency}}</td> </tr> </table>

初學(xué)Angular,如果,有哪里不正確,請(qǐng)各位指出。

問(wèn)題解答

回答1:

第一個(gè)tr后面多了一個(gè)/tr吧 這樣里面沒(méi)東西,所以已經(jīng)repeat了只是repeat出了一堆空

相關(guān)文章:
主站蜘蛛池模板: 湘潭市| 双辽市| 磐石市| 扶余县| 利川市| 喀什市| 梓潼县| 成武县| 宝应县| 金湖县| 崇信县| 定襄县| 新津县| 镇江市| 平远县| 永清县| 石门县| 年辖:市辖区| 蕲春县| 淳化县| 赤峰市| 普兰店市| 永福县| 阳信县| 繁峙县| 普格县| 故城县| 富源县| 思南县| 汶川县| 微博| 北安市| 辽宁省| 长宁县| 秦皇岛市| 井陉县| 清涧县| 郓城县| 泽普县| 阳新县| 棋牌|