我已經重複一個div通過角JS ng-repeat
<div ng-repeat="exampleData in example">
<input type="text" id="{{ $index }}percentage"/>
<button type="btn btn-success" ng-click="submitted('{{ $index }}fromHours')">Submit</button>
</div>
所以,當我點擊提交按鈕提交方法將輸入精密組件ID通過爲被稱爲參數吧,
請看看下面的JS代碼:
$scope.submitted = function(percentage){
console.log($('#'+percentage).val());
}
現在,當我使用的參數,並打印出它的價值我得到的錯誤,說
Syntax error, unrecognized expression: #{{ $index }}percentage
我應該如何獲得輸入類型與{{$指數}}百分比ID的確切值
我已經寫$指數具有獨特的ID作爲文本框將被重複很多倍。
請幫幫忙,在此先感謝:)
感謝它現在的工作:) – Harish
@Harish不錯。如果這有幫助,一定要檢查正確的答案 –