我试图用Angular JS控制data-toggle = 'collapse'
我有类似
的东西<a href="#" ng-click="clickMe()"
<div id="wrapper"
data-toggle="collapse"
data-target="#test">
texts and elements...
</div>
<div id='test'>
test div….
</div>
JS
$scope.clickMe = function() {
//I want to collapse the test div in angularjs when I click the <a> tag.
//I can archive that by using the codes below but I want to use the angular
//way to do this
$('#test').collapse('hide')
}
我如何以Angular方式进行操作?谢谢!
答案 0 :(得分:1)
您可以使用ng-show执行此操作并按住ng键单击切换范围变量。
<div ng-click="test1Showing=!test1Showing">
texts and elements...
</div>
<div ng-show='test1Showing'>
test div….
</div>
或者如果你想删除元素,不只是display:none;您可以使用ng-if代替ng-show。