国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

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

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

問題描述

<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>

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

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

代碼更改成這樣,可以顯示出數據,說明數據已經綁定成功了,為什么使用這段代碼,無法顯示數據?

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

初學Angular,如果,有哪里不正確,請各位指出。

問題解答

回答1:

第一個tr后面多了一個/tr吧 這樣里面沒東西,所以已經repeat了只是repeat出了一堆空

相關文章:
主站蜘蛛池模板: 万盛区| 甘孜县| 固安县| 习水县| 珲春市| 偃师市| 乌审旗| 义乌市| 嘉禾县| 南涧| 全南县| 丹巴县| 佛坪县| 阿荣旗| 西吉县| 竹溪县| 全南县| 牟定县| 南康市| 武山县| 永川市| 逊克县| 岗巴县| 丰都县| 双峰县| 武宁县| 泸定县| 玉溪市| 大连市| 五河县| 垫江县| 尚志市| 宣威市| 丘北县| 商水县| 蒲江县| 布拖县| 岢岚县| 呈贡县| 东丰县| 滦南县|