ng-disabled on buttons,但当我更改值时它不会刷新
ng-disabled on buttons, but it doesn't refresh when I change value
我有以下按钮:
<button id="facebook" type="button" ng-disabled="signing" ng-click="fblogin()">FACEBOOK</button>
<button id="google" type="button" ng-disabled="signing" ng-click="googleLogin()">GOOGLE</button>
例如,当我按下 Google 按钮时,它会执行以下操作:
$scope.googleLogin = function() {
$scope.signing = true;
document.getElementById('googleAuth').click();
};
我的 gapi 这样做:
gapi.load('auth2', function(){
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
client_id: 'MY ID',
cookiepolicy: 'single_host_origin',
scope: 'email',
// Request scopes in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
attachSignin(document.getElementById('googleAuth'));
});
然后按钮被禁用,这很好,因为我将 $scope.signing
更改为 TRUE。
但是当我回来时,我这样做了:$scope.signing = false;
没有任何变化,按钮保持禁用状态。为什么它不能自行启用,当我将签名更改为 false 时,我是否需要让 html 以某种方式知道刷新按钮的状态?
感谢 Surajck,我让它工作,将它设置在 $apply 中,就像这样:
$scope.$apply(function () {
$scope.signing = false;
});
我有以下按钮:
<button id="facebook" type="button" ng-disabled="signing" ng-click="fblogin()">FACEBOOK</button>
<button id="google" type="button" ng-disabled="signing" ng-click="googleLogin()">GOOGLE</button>
例如,当我按下 Google 按钮时,它会执行以下操作:
$scope.googleLogin = function() {
$scope.signing = true;
document.getElementById('googleAuth').click();
};
我的 gapi 这样做:
gapi.load('auth2', function(){
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
client_id: 'MY ID',
cookiepolicy: 'single_host_origin',
scope: 'email',
// Request scopes in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
attachSignin(document.getElementById('googleAuth'));
});
然后按钮被禁用,这很好,因为我将 $scope.signing
更改为 TRUE。
但是当我回来时,我这样做了:$scope.signing = false;
没有任何变化,按钮保持禁用状态。为什么它不能自行启用,当我将签名更改为 false 时,我是否需要让 html 以某种方式知道刷新按钮的状态?
感谢 Surajck,我让它工作,将它设置在 $apply 中,就像这样:
$scope.$apply(function () {
$scope.signing = false;
});