3
我有以下的控制器......我想從一個HTML輸入name
和rating
attibute,但我得到的錯誤TypeError: angular.element(...).getAttribute is not a function
的getAttribute值與角
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>
是否有另一種方法可以做到這一點?
這對我給予未定義 –
不應該納克點擊是否點擊? – nikhil
Typo,它實際上是'ng-click' - 更新問題 –