我正在使用aurelia并希望在视图中而不是在视图模型中过滤集合(数组)。
我正在尝试以下语法来做到这一点:
<div class="col-sm-7 col-md-7 col-lg-7 ${errors.filter(function(err){return err.Key==='car.Model';}).length >0? 'alert alert-danger' :''}">
<span repeat.for="error of errors">
<span if.bind="error.Key==='car.Model'">
${error.Message}
</span>
</span>
</div>
我在浏览器控制台中收到以下错误:
Error: Parser Error: Missing expected ) at column 28 in [errors.filter(function(err){return err.Key==='car.Model';]
.
这在 angularJS 中是可能的,如下所示:
<div class="small-7 medium-7 large-7 columns end">
<span class="error" ng-repeat="error in errors | filter:{ Key: 'car.Model'}">
<span class="error-message">
{{error.Message}}
</span>
</span>
</div>
类似的事情在aurelia也可能吗?
我也很想知道如何repeat.for
在 aurelia 中过滤集合/数组(类似于ng-repeat
)。我尝试以类似的方式使用过滤器功能,但它也不起作用,并且出现了类似的错误。