26
rated 0 times
[
28]
[
2]
/ answers: 1 / hits: 16909
/ 9 Years ago, fri, july 10, 2015, 12:00:00
I have the following controller... I'm trying to get the name
and rating
attibute from an HTML input, but I get the error TypeError: angular.element(...).getAttribute is not a function
app.controller('courseReview', function ($scope, $http) {
$scope.rateThis = function rateThis(el){
var elName = angular.element(el).getAttribute('name');
var rating = angular.element(el).getAttribute('rating');
document.getElementById(elName+'Rating').value = rating;
}
});
HTML
<div ng-controller=courseReview>
<!-- radio input -->
<input class=star-5 id=wstar-5 rating=5 type=radio name=welcome ng-click=rateThis(this)/>
</div>
Is there another way to do this?
More From » angularjs