I am hiding a button in Jquery function which is called at data-ng-click of a label in html page. but the button is getting hide only double click of the label not in single click. i want it in single click.
<label id="LabelApplications" class="Applications" style="" data-ng-click="GetBuildServerConfigData(this)">application name</label>
$scope.GetBuildServerConfigData = function (SelectedItem) {
$('#button2').hide();
$("#savebutton").hide();
}
While your question does not mention anything about the GetBuildServerConfigData
function, if it is just the hiding that you need to accomplish you can do that like so:
<label id="LabelApplications" ng-init="showButton = true" class="Applications" style="" data-ng-click="GetBuildServerConfigData()" ng-show="showButton">application name</label>
And in your controller:
//Controller code
$scope.GetBuildServerConfigData = function() {
//ajax call (presumably)
//.then(function(response) {
$scope.showButton = false;
//});
}
If this is all that needs to be done, you don't even need the this
variable passed to the function, like you would do in jQuery
Note: Also, ideally you shouldn't be mixing jQuery DOM manipulation with AngularJS. Do it the Angular way :)
Working snippet below:
var app = angular.module("testApp", []); app.controller("testCtrl", function($scope) { $scope.GetBuildServerConfigData = function() { $scope.showButton = false; } });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="testApp" ng-controller="testCtrl"> <label id="LabelApplications" ng-init="showButton = true" class="Applications" style="" data-ng-click="GetBuildServerConfigData()" ng-show="showButton">application name</label> </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.