我下面就NETTUTS教程构建Web应用程序从头AngularJS 的,但使用谷歌从US preadsheet我自己的JSON电话。除了搜索过滤器似乎并不奏效。
I am following the tutorial on nettuts Building a Web App From Scratch in AngularJS but using my own json call from google spreadsheet. Except the search filter doesn't seem to be working.
编辑:意见的基础上,下面是简单的例子
Based on feedback, here is simplified example
app.controller("mainController", function($scope, $http){
$scope.results = [];
$scope.filterText = null;
$scope.init = function() {
var sheet = "od6"; //upcoming classes
var key = "0AhVWrVLsk5a5dDJyaW1LMXFEVk1UY0FPVlBVcHd1bGc";
var url = "http://spreadsheets.google.com/feeds/list/" + key + "/" + sheet + "/public/values?alt=json-in-script";
$http.jsonp(url + '&callback=JSON_CALLBACK').success(function(data) {
angular.forEach(data, function(value, index){
angular.forEach(value.entry, function(classes, index){
$scope.results.push(classes);
});
});
}).error(function(error) {
});
};
});
之后,它似乎是很容易建立,就像:
After that it seems to be fairly easy to set up, just like:
<input type="text" ng-model="filterText" placeholder="Enter text here">
<ul>
<li ng-repeat="classes in results | filter:filterText>
<h3>{{classes.gsx$title.$t}}</h3>
<p>{{classes.gsx$description1.$t}}</p>
<ul>
<li><strong>Start:</strong> {{classes.gsx$start.$t}} </li>
<li><strong>End:</strong> {{classes.gsx$finish.$t}} </li>
<li><strong>Price:</strong> {{classes.gsx$price.$t}} </li>
<li><strong>Seats:</strong> {{classes.gsx$spots.$t}} </li>
<li><strong><a href = "{{classes.gsx$url.$t}}">Sign up now</a></strong></li>
</ul>
</li>
</li>
</ul>
但是当我运行filterText搜索,它不给任何结果。该页面出现空。这里到处是code的例子。
but when i run filterText search, it doesn't give any results. the page comes up empty. here is full code example.
http://plnkr.co/edit/ZnVqyeQ9OWqwzjIEplOU?p=$p$ PVIEW
下面是JSON响应:
巨大的感谢!
既然你试图筛选包裹在对象中的文本,你可以试试这个方法:
Since you try to filter the text wrapped in object, you can try this approach:
这将显示包含标题中的 filterText
搜索栏键入任何记录。
This will show records with title containing whatever typed in the filterText
search bar.
<li ng-repeat="classes in results | filter:{gsx$title.$t: filterText} | isCategory:categoryFilter">