$scope.facePanel = false;
$scope.showFace = function () {
$scope.facePanel = !$scope.facePanel;
}
这是我在controller里面的代码
$scope.facePanel = false;
$scope.showFace = function () {
$scope.facePanel = !$scope.facePanel;
}
这是我在controller里面的代码
js
angular.directive('aDirective', [function(){
return {
restrict: 'E',
template:'<div a-directive><div ng-show="facePanel">元素</div><button ng-click="showFace()">点击</button></div>',
replace: true,
link: function(scope, ele, attr){
scope.facePanel = false;
scope.showFace = function () {
scope.facePanel = !$scope.facePanel;
}
}
}
}])
html
<a-directive></a-directive>
都隐藏了你还怎么点击元素再让显示?
如果是点击一个button让另一个元素隐藏的话还是很好实现的!
html
不用函数了,稍微改下就行
<button ng-click="$scope.facePanel=!$scope.facePanel">点击</button>