Reputation: 31
I have in html page like
<input type="hidden" id="disqusId" ng-value="disqusId">
and I am using that value in script in same html page
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
var disqus_shortname = 'lingaraj';
var disqus_identifier = document.getElementById("disqusId").value;//its not getting value
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {`enter code here`
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
Upvotes: 1
Views: 1355
Reputation: 35
AngularJs - use ng-model.
<input type="hidden" id="disqusId" name="disqusId" ng-model="disqusId">
in your controller try to print in console ->
`console.log($scope.disqusId);
to me with angular i dont see the necessity to have a hidden value as you can just save in model / $scope
eg : you have save all your form in $scope.form and extract all model related to it
$scope.form.hiddenValue
i have prepared something in plunker
Upvotes: 0
Reputation: 5466
To Retrieve
angular.element(document.getElementsByName('disqusId'][0]).val();
or
<input type="hidden" name="disqusId" ng-init="disqusId='your desired value'" ng-model="disqusId">
To bind data then you can use anyone of the following
<input type="hidden" name="disqusId" value="{{disqusId}}" />
<input type="hidden" name="disqusId" ng-value="disqusId" />
Upvotes: 1
Reputation:
In angularjs not jquery.
<input type="hidden" id="disqusId" ng-model="disqusId">
and in your js file .
console.log($scope.disqusId);
Upvotes: 1