不知道如何做到这一点,但我想将一个字符串作为参数传递给ng-click,然后将它作为函数中的条件。这样的事情呢?
<div class="row">
<div class="col-md-12 text-center mb-5">
<div class="btn-group">
<button class="btn btn-primary" ng-click=""><span class="ion-plus-circled mr-2"></span>New</button>
<button class="btn btn-outline-primary" ng-click="filter_emails('inbox')"><span class="ion-archive mr-2"></span>Inbox</button>
<button class="btn btn-outline-primary" ng-click=""><span class="ion-paper-airplane align-middle mr-2"></span>Shielded</button>
</div>
</div>
</div>
然后在我的控制器中:
$scope.filter_emails = function(category) {
if (category == "inbox") {
$scope.grouped = group(inbox($scope.emails));
}
else {
$scope.grouped = group($scope.emails);
}
}
这不起作用或者我显然不会发布问题,那么对此有什么正确的解决方法呢?
答案 0 :(得分:1)
如果您想传递一个字符串,请将其括在 quotes
ng-click="filter_emails('inbox')"