簡體   English   中英

將過濾器與angularjs控制器一起使用

[英]Use filter with angularjs controller

當復選框被選中時,我使用此代碼在過濾器中添加屬性。

<input ng-model="filter['model']['first']" value="first" type="checkbox" name="model">

我試圖在控制器中執行此操作,以獲取stateparams值並預選復選框

$scope.filter = {};
$scope.model=$stateParams.model;
if($scope.model == 'first')
{filter="['model']['first']"}
else if if($scope.type == 'second')...

但是它不起作用,過濾器不起作用,而且我不再與任何元素匹配。

這就是你的本意嗎?

$scope.filter = {};
$scope.model=$stateParams.model;
if($scope.model == 'first')
{
    $scope.filter="['model']['first']"
}
else if($scope.type == 'second'){
    ...
}

如果是這樣,您的問題是這樣的:

$scope.filter = {};
$scope.model=$stateParams.model;
if($scope.model == 'first')
{
    $scope.filter['model'] = {};
    $scope.filter['model']['first'] = ???;
}
else if($scope.type == 'second'){
    ...
}

我不確定您也在嘗試設置['model']['first']

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM