1
我有一個問題,我們如何用angularjs來實現這一點。如果在其他地方點擊,使div隱藏AngularJs
##的Html ##
<input ng-model="text" ng-change= "datashow(text)">
<div ng-show="showit" ng-init="showit = false">
//contains data i got from scope
{{ query }}
</div>
## JS:##
$scope.datashow=function(text){
if(text.length > 0)
$http.post('url' ,text).sucess(function(data){
$scope.showit = true;
$scope.query = data;
});
}else{
$scope.showit = false;
}
}
所以這是我得到每當我的用戶搜索的數據。如果他在div外點擊,那我該如何隱藏showit class。
什麼是最好的做法,在角度做!
此功能完美。我不介意使用jQuery。在使用角度時,我很懷念它的簡單性。 – maaw