我有一个要求,当单击一个元素(Button)时应该改变另一个元素属性。 我可以通过jquery来完成。但我想忽略我的角度项目中的jQuery。通过angularjs中的另一个元素获取元素
在HTML中,
<input type=password />
<button ngclick="changeToTxt()">Change type password to text</button>
在控制器,
app.controller('loginPage', function ($scope) {
$scope.changeToTxt = function() {
**// need to get the password element and need to change type = text.....**
}
});
有没有一种方法(或不同的/最好的方法)由控制器做什么?或者需要为此写一条指令?
这是跨浏览器兼容吗?我认为它不适用于IE。你有没有在不同的浏览器上试过它? – user1537766 2014-12-03 06:51:25
是的。我已在所有平台上进行过测试。它将一切工作。 – simon 2014-12-03 06:54:06
适用于IE9及以上版本,不在下面http://www.universalwebservices.net/web-programming-resources/javascript/change-input-element-type-using-javascript – 2014-12-03 07:03:17