Consider we have page status list.
1 |
$scope.PageStatusList = ["On Hold", "Start", "Done"]; |
then out html looks like as,
1 2 3 4 5 6 7 8 9 10 |
<md-input-container> <label>Filter by Page Status:</label> <md-select multiple ng-model="filterData.selectedPageStatus"> <md-button class="select-all-btn" value="all" ng-if="filterData.selectedPageStatus.length != PageStatusList.length" ng-click="selectAllPageStatus()">SELECT ALL</md-button> <md-button class="select-all-btn" value="all" ng-if="filterData.selectedPageStatus.length == PageStatusList.length" ng-click="deselectAllPageStatus()">DESELECT ALL</md-button> <md-option value="{{pageStatus}}" ng-repeat="pageStatus in PageStatusList"> {{pageStatus}} </md-option> </md-select> </md-input-container> |
and her we have 2 functions for select/deselect all.
1 2 3 4 5 6 7 |
$scope.filterData.selectedPageStatus = []; $scope.selectAllPageStatus = function () { $scope.filterData.selectedPageStatus = $scope.PageStatusList; }; $scope.deselectAllPageStatus = function () { $scope.filterData.selectedPageStatus = []; }; |
If you have any query then drop a comment.:)
Can you provide same version of code in Angular 5
I have HTML like this
Select All
{{p.name}}
and component like this
pro: any =[];
constructor(private config: ConfigService) { }
getProject() {
this.config.getProject().subscribe(
data => { this.pro = data[‘projects’]},
err => console.error(err),
() => console.log(‘done loading projects’)
);
}
ngOnInit() {
this.getProject();
}
Hello Koushal,
Here is your requested query hope it helps you.