JavaScript ngModel on a img ngmodelchange,ngmodel angular,ngmodeloptions,ngmodeloptions u003d standalone true,ngmodel checkbox,

I'm trying to make something easy but, it doesn't work. I have this html

<div  class="positionDiv">
     <img class="eyes" ng-model="showPasswordIsChecked" ng-click="afficherMdp()"  ng-controller="creationCompteController"  src="images/eye.png" />
</div>
{{ showPasswordIsChecked }}

and this javascript

angular.module('starter').controller('creationCompteController',[
    '$scope',   
     function ($scope)
    {


        $scope.showPasswordIsChecked = false;


        //Affichage du template html
        $scope.afficherMdp = function()
        {
            if($scope.showPasswordIsChecked==true)
            {
                $scope.showPasswordIsChecked=false;
                alert($scope.showPasswordIsChecked);
            }else{
                $scope.showPasswordIsChecked=true;
                alert($scope.showPasswordIsChecked);
            }

        }

    }]);

I want, when i click on my image to change the value of showPassword to true or false. In the js file, the enter in the function, but in the html {{ showPasswordIsChecked }} shows nothing, as if the variable doesn't exist. How could I do please ?

Answer:1

You can't bind an <img /> to a variable with ng-model :https://docs.angularjs.org/api/ng/directive/ngModel

You must use it on an input (or an element with an input behavior).

But you can do like this :

angular.module('test', []).controller('creationCompteController', function($scope) {
  $scope.showPasswordIsChecked = false;
});
#my-checkbox {
  visibility: hidden;
  opacity: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<div ng-app="test">
  <div ng-controller="creationCompteController">
      <label for="my-checkbox">
          <input id="my-checkbox" type="checkbox" ng-model="showPasswordIsChecked" />
          <img src="http://icons.iconarchive.com/icons/custom-icon-design/mono-general-4/128/eye-icon.png" />
      </label>
    
       {{ showPasswordIsChecked }}
  </div>  
</div>
Answer:2

Here is the demo http://dojo.telerik.com/OjaPa You are printing model out of controller scope so that it is happening Please check whether it is helpful or not

 <div ng-controller='creationCompteController'>
  <div  class="positionDiv">
   <img class="eyes" ng-model='showPasswordIsChecked'  ng-click="afficherMdp()"   src="images/eye.png" />
 </div>
 {{ showPasswordIsChecked }}
</div>

Hope this may help you.

Answer:3

I am very new to React, currently doing a small project of using GitHub API to return a search result via AJAX and be able to list that result on the screen. Currently I am using a for loop to iterate ...

I am very new to React, currently doing a small project of using GitHub API to return a search result via AJAX and be able to list that result on the screen. Currently I am using a for loop to iterate ...

  1. react setstate only if changed
  2. react setstate only one property
  3. react setstate only one property of object
  4. react setstate only part of state
  5. react setstate only if mounted
  6. react setstate change only one property
  7. react setstate update only one property
  8. react setstate only once

I'm working on a simple web form for teachers in my building to generate HTML pages with embedded videos to use locally (our substitutes can't get on the Internet to play videos; this is a workaround)....

I'm working on a simple web form for teachers in my building to generate HTML pages with embedded videos to use locally (our substitutes can't get on the Internet to play videos; this is a workaround)....

  1. iframe source from html
  2. source from folder html
  3. javascript source from html
  4. download source from html
  5. source html
  6. source html tag
  7. source html code
  8. source html element
  9. source html image
  10. source html online
  11. html5 source
  12. source html video
  13. source html viewer
  14. source html css
  15. source html chrome
  16. source html media
  17. source html picture
  18. source html img
  19. source html editor
  20. source html page

I am trying to authenticate a user from Angular 2 app by calling an express api that provides a JWT token upon success. I have got a doubt to clear. Do we ask express to set the cookie or is it ...

I am trying to authenticate a user from Angular 2 app by calling an express api that provides a JWT token upon success. I have got a doubt to clear. Do we ask express to set the cookie or is it ...

  1. xsrf-token cookie angular

I'm trying to create a component using vue.js, where the component contains a font-awesome icon, which is supplied in template. For example, I'd like to be able to use <big-nav-item icon="fa-phone"...

I'm trying to create a component using vue.js, where the component contains a font-awesome icon, which is supplied in template. For example, I'd like to be able to use <big-nav-item icon="fa-phone"...