admin管理员组文章数量:1289604
Just i want to get the ng-model hidden field value using javascript.
<input type="hidden" name="Latitude" id="sLatitude" ng-model='sLatitude'>
Just i want to get the ng-model hidden field value using javascript.
<input type="hidden" name="Latitude" id="sLatitude" ng-model='sLatitude'>
Share
Improve this question
edited Feb 1, 2017 at 10:44
Chandan Rai
10.4k2 gold badges21 silver badges29 bronze badges
asked Feb 1, 2017 at 9:38
MohanKanalMohanKanal
711 gold badge1 silver badge7 bronze badges
4
-
3
In controller, you can get is by
$scope.sLatitude
. – Tushar Commented Feb 1, 2017 at 9:39 - check this out – Elmer Dantas Commented Feb 1, 2017 at 9:40
- Hope this helps you. – Blauharley Commented Feb 1, 2017 at 9:41
- do u want get the value to controller or outside of the controller – Sachila Ranawaka Commented Feb 1, 2017 at 9:43
6 Answers
Reset to default 2it took me some time to find out, but I think the answer is
angular.element(YOUR_ANGULAR_ELEMENT_HERE).attr('ng-model');
As an answer you 'll get the value of the ng-model, "sLatitude".
I am leaving it here just in case someone else needs it.
you can get sLatitude value by :
console.log($scope.sLatitude);
If you want that value within scope , just access as $scope.sLatitude
If you want that value outside the scope, document.getElementById("sLatitude").value
You can access by calling:
angular.element(document.getElementById('sLatitude')).scope().sLatitude
You can get the value of Latitude by write this in java script in your controller like this. var latotudeValue = $scope.sLatitude;
You can get the value of Latitude by $scope.
var latitudeValue = $scope.sLatitude;
OR
if you have value attribute in input control then
var latitudeValue = document.getElementsById("sLatitude").value;
本文标签: angularjsGet angular ngmodel value in javascriptStack Overflow
版权声明:本文标题:angularjs - Get angular ng-model value in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741415684a2377494.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论