AngularJS: can't change input type

后端 未结 5 2195
梦毁少年i
梦毁少年i 2020-12-06 04:40

Whenver I have an Angular expression as a value to input\'s type, it won\'t work:



        
5条回答
  •  抹茶落季
    2020-12-06 05:38

    yes you can ... at least now :)

    HTML:

    JS:

    var myApp = angular.module('myApp', []);
    myApp.controller('mainCtrl', ['$scope', function( $scope ){
    
      // Set the default value of inputType
      $scope.inputType = 'password';
    
      // Hide & show password function
      $scope.hideShowPassword = function(){
        if ($scope.inputType == 'password')
          $scope.inputType = 'text';
        else
          $scope.inputType = 'password';
      };
    }]);
    

    source: http://codepen.io/gymbry/pen/fJchw/

    UPDATE 17/04/2015:

    I have randomly changed Angular version in above Codepen and this seems to work from version 1.0.2 ... Hope this help ...

提交回复
热议问题