Angularjs,ng点击字体真棒span不工作,但在按钮上工作



我有这个代码:

<input is-password="checkPassword" autocomplete="off" required
ng-model="vm.simulate.rutDeudor" type="password" minlength="3"
id="rut-deudor-field" tabindex="2"
ng-attr-type="{{ isPassword ? 'password' : 'text' }}">
<button ng-click="checkPassword=!checkPassword">Mostrar</button>
<span ng-click="checkPassword=!checkPassword" class="fa fa-lg fa-eye"> 
</span>

这个想法是使用span而不是button,我不知道为什么按钮有效,但跨度无效。

这是控制器:

angular.module('app.factoringCotizarDocs')
.controller('sincronizarCarpetaTributariaModalCtrl', sincronizarCarpetaTributariaModalCtrl)
.directive('isPassword', function() {
return {
restrict : 'A',
scope: {
isPassword: '=isPassword'
},
link: function (scope, element, attrs) {
scope.$watch('isPassword', function(a, b){
element.attr('type', a ? 'text' : 'password')
})
}
}
});

ng-clickspan配合良好。所以我认为问题出在你的项目中。

这是一个演示plunker

最新更新