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")%>'"