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
Post a Comment