expand and open collapse depend on the value angular
I am wonder how you can achieve a conditional situation that able to open
one of the collapse. Say, I got some value, if country is CZ, I want to
open collapse 1, else if country is USA, it should open collapse 2.
<div ng-controller="CollapseDemoCtrl">
<button class="btn" id="btn" ng-click="isCollapsed =
!isCollapsed">CZ</button>
<hr>
<div collapse="isCollapsed">
<div>CZ</div>
</div>
</div>
<div ng-controller="CollapseDemoCtrl">
<button class="btn" id="btn" ng-click="isCollapsed =
!isCollapsed">USA</button>
<hr>
<div collapse="isCollapsed">
<div> USA</div>
</div>
</div>
Here is the controller
var app = angular.module('app', ['ui.bootstrap']);
app.controller('CollapseDemoCtrl', function($scope) {
$scope.isCollapsed = true;
//not working code from here
$scope.values = $document.getElementbyId('btn').innerHTML;
if($scope.values==1)
$scope.isCollaspe=false;
});
I am really curious of what will the correct way to do it. Because my code
currently does not perform the correct thing. Any suggestions?
No comments:
Post a Comment