我正在尝试为我的filter
数据创建自定义scope
,并且我的JSON
文件中包含评级,您可以从下拉列表中选择看到正面或负面评级或所有默认行为。现在我将数据加载到JSON
。我不知道如何传递数据和更新视图
js 文件:
var self = this;
self.data = [{"subject":"math","grade":1},
{"subject":"chemistry","grade":-1},
{"subject":"gym","grade":0.8},
{"subject":"music","grade":-0.8}]
self.rating = function(){
}
HTML 的
<select name="grade" id="" ng-model="rating" >
<option value="all">all</option>
<option value="positive">positive</option>
<option value="negative">negative</option>
</select>
<ul>
<li ng-repeat="opt in self.data | orderBy:'grade' |
filter:self.rating"">
{{opt.subject +" " + opt.grade}}
</li>
</ul>