Reputation: 3051
I'm trying to get the "validacion"
property of an HTML element.
console.log (element[0]);
This returns me:
<input class="estilo_input_text ng-pristine ng-untouched ng-valid ng-empty" id="asunto" name="asunto" ng-model="asunto" placeholder="Asunto" type="text" validacion="required">
How can I access the "validacion"
property?
Upvotes: 3
Views: 10583
Reputation: 8623
Don't know why you need to do this:
You'd better use the directive way to get the element.
Or you can use Angular jqLite
API:
angular.element('#asunto').attr('validacion')
Upvotes: 1
Reputation: 222522
You can simply do with getAttribute
:
console.log(element[0].getAttribute("validacion"));
Upvotes: 0
Reputation: 686
I think this is the answer you're looking for.
Since you're using Angular
and you're implementing ng-model="asunto"
why not make it like this in html.
<input class="estilo_input_text ng-pristine ng-untouched ng-valid ng-empty" id="asunto" name="asunto" ng-model="asunto" placeholder="Asunto" type="text">
<button ng-click="get_model(asunto)"></button>
In your JS:
$scope.asunto = "model";
$scope.get_model = function (string) {
console.log(string)
}
I think this might work becuase you're already using ng-model
why not use ng-model
instead.
Upvotes: 0
Reputation: 5571
You need the javascript Element.getAttribute()
method:
console.log(element[0].getAttribute("validacion"));
Upvotes: 7