Javascript img上的ngm模型
我试着让事情变得简单,但它不起作用。我有这个htmlJavascript img上的ngm模型,javascript,angularjs,angular-ngmodel,Javascript,Angularjs,Angular Ngmodel,我试着让事情变得简单,但它不起作用。我有这个html <div class="positionDiv"> <img class="eyes" ng-model="showPasswordIsChecked" ng-click="afficherMdp()" ng-controller="creationCompteController" src="images/eye.png" /> </div> {{ showPasswordIsChecke
<div class="positionDiv">
<img class="eyes" ng-model="showPasswordIsChecked" ng-click="afficherMdp()" ng-controller="creationCompteController" src="images/eye.png" />
</div>
{{ showPasswordIsChecked }}
我想,当我点击我的图像时,将showPassword的值更改为true或false。在js文件中,函数中的enter键,但在html{{{showPasswordIsChecked}}
中没有显示任何内容,就好像变量不存在一样。我该怎么办?您不能绑定
{{showPasswordIsChecked}
这是演示
您正在将模型打印出控制器范围,以便它发生
请检查它是否有用
<div ng-controller='creationCompteController'>
<div class="positionDiv">
<img class="eyes" ng-model='showPasswordIsChecked' ng-click="afficherMdp()" src="images/eye.png" />
</div>
{{ showPasswordIsChecked }}
</div>
{{showPasswordIsChecked}
希望这能对您有所帮助。我认为您的代码可以正常工作 这里是链接
<div ng-controller='creationCompteController'>
<div class="positionDiv">
<img class="eyes" ng-model='showPasswordIsChecked' ng-click="afficherMdp()" src="images/eye.png" />
</div>
{{ showPasswordIsChecked }}
</div>
$scope.afficherMdp = function()
{
if($scope.showPasswordIsChecked==true)
{
$scope.showPasswordIsChecked=false;
alert($scope.showPasswordIsChecked);
}else{
$scope.showPasswordIsChecked=true;
alert($scope.showPasswordIsChecked);
}
}