1

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>
1
  • Your code writing in jquery and your tag is angularjs. clarify about this. Commented Jul 31, 2015 at 7:43

3 Answers 3

1

In angularjs not jquery.

         <input type="hidden" id="disqusId"   ng-model="disqusId">    

and in your js file .

console.log($scope.disqusId);
Sign up to request clarification or add additional context in comments.

1 Comment

Actually $scope.discusId is set in Controller and in html <input type="hidden" id="disqusId" ng-value="disqusId"> in that same page i added above script ,how can i assign that hidden value to var disqus_identifier
1

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" />

1 Comment

i tried what you suggested but not working ..... As i mentioned in my question my controller in controller.js and declared and assigned $scope.disqusId and <input type="hidden" ng-value ="{{disqusId}}" /> and script in same html page, how can i get the value of this and assign to var disqus_identifier = ? (here how to get value of disqusId) in script not in controller.js , i tried using document.getElementById('disqusId').value but not getting value
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.