After clicking on the submit button, I want the ng-if condition to activate in the DOM so that I can access the properties of the input element or apply a class to it.
<div ng-app="myModule">
<div ng-controller="myController">
<div ng-if="addInput">
<input value="123456" id="addInput">
</div>
<input type="submit" ng-click="login()" value="Login">
</div>
</div>
The controller code is as follows:
var module = angular.module("myModule", []);
module.controller("myController", function($scope) {
$scope.addInput=false;
$scope.login = function () {
$scope.addInput = true;
var invar= document.getElementById('addInput');
var invalue = invar.value();
console.log("value was " + invalue);
};
});
Check out this JSFiddle example: https://jsfiddle.net/f0aewhuy/. I'm encountering an error in the dev console while testing.
Any suggestions on how I could make this work?
Thanks!