admin管理员组文章数量:1332345
i wants to access session value from angular js.or set it in a text field.But its not working.
<input type="text" id="uname" value="<%=session.getAttribute("username")%>" ng-model="username" readonly="readonly">
when i set the value of normal text field its working, like
<input type="text" id="uname" value="<%=session.getAttribute("username")%>" readonly="readonly">
but after adding ng-model
its not working.
How i will do this?Please anybody help me.
i wants to access session value from angular js.or set it in a text field.But its not working.
<input type="text" id="uname" value="<%=session.getAttribute("username")%>" ng-model="username" readonly="readonly">
when i set the value of normal text field its working, like
<input type="text" id="uname" value="<%=session.getAttribute("username")%>" readonly="readonly">
but after adding ng-model
its not working.
How i will do this?Please anybody help me.
-
It will be good if you move the
session.getAttribute("username")
to controlelr – Sravan Commented Mar 29, 2017 at 11:08 - How will do this?@Sravan – S dg Commented Mar 29, 2017 at 11:13
- Use JSP on JavaScript files is clearly a bad solution. And controller is placed in JS. So if you want to use this approach, you need e client-server munication get session values from server. – Anton Stepanenkov Commented Mar 29, 2017 at 11:23
1 Answer
Reset to default 5It's angular's normal behavior. Try to use
ng-value="'<%=session.getAttribute("username")%>'"
which is better
or
ng-init="username = '<%=session.getAttribute("username")%>'"
本文标签: javascriptHow to access Session value from AngularjsStack Overflow
版权声明:本文标题:javascript - How to access Session value from Angularjs.? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742325839a2453703.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论