angularjs - How to set value to $rootScope from text field on button click -


following want do, in javascript style. @ loading html div (token) should show ever value in $rootscope.token.then when ever button pressed after typing text in input field (tokeninp), need update $rootscope.token , displayed value in html.

document.getelementbyid("token").innerhtml = $rootscope.token;  function settoken(){     $rootscope.token = document.getelementbyid("tokeninp").value;     document.getelementbyid("token").innerhtml = $rootscope.token; } 

how using angularjs (im new it)

in html

    <span ng-bind="token"></span>    <input type='text' ng-model='tokenvalue'> </input> <input type="button" ng-click='modifiedtokenvalue ()'/> 

in controller

 $scope.token = $rootscope.token;   $scope.modifiedtokenvalue = function(){    $rootscope.token = $scope.tokenvalue;    $scope.token = $scope.tokenvalue;  }; 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -