取消屏蔽纯文本的密码,并在单击复选框时再次屏蔽它

时间:2016-06-28 04:42:45

标签: .net angularjs asp.net-mvc html5 model-view-controller

我在html5中有一个密码类型输入元素,如下面的基于角度mvc的应用程序。

我要求在此附近有一个复选框,当用户点击chekcbox时,我们在同一密码输入类型文本框中显示屏蔽密码文本作为纯文本,该文本框位于代码下方。再次,当用户取消选中该复选框时,我们应该屏蔽纯文本以掩盖:)看起来很简单,我是新来的,有人可以帮我提供可能的代码

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
    if(indexPath == selectedIndexPath){
        var cellHeight = 100 // Assume this is the height when deptProfile.count = 0
        cellHeight = cellHeight + 44 * deptProfile.count
        return cellHeight
    }
    return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
}

2 个答案:

答案 0 :(得分:3)

您可以根据自己的情况使用ng-showng-if指令。

通过以下代码段,不同类型的输入将在dom上切换。

<input type="password" name="password"
                               ng-model="model.password"
                               placeholder="Please type your password"
                               ng-show="!showPassword">

<input type="text" name="password"
                               ng-model="model.password"
                               ng-show="showPassword">

<input type="checkbox" ng-model="showPassword">

工作Fiddle

希望它有所帮助。

答案 1 :(得分:0)

HTML

module.exports = __webpack_require__.p + "32aa2ecb4810e9d55a3b870c0eab59eb.svg";

的js

<section ng-app="myApp" ng-controller="mainCtrl">
  <input type="{{inputType}}" placeholder="Put your password" />
  <input type="checkbox" id="checkbox" ng-model="pass_cb" ng-click="togglePassword()" />
  <label for="checkbox" ng-if="pass_cb === true">Hide password</label>
  <label for="checkbox" ng-if="pass_cb === false">Show password</label>  
</section>
<script src="http://code.angularjs.org/1.2.13/angular.min.js"></script>

请参阅此小提琴演示http://jsfiddle.net/5DMjt/7278/