Ad

Angular Js Ng-model Under Jstl C:param Value

- 1 answer

How to I see {{angularJSvalue}} under " " ? The h2 part is working fine, but I don't know how to put it under " " signs. That is what i get pussing the filter button: ...students.html?fname=%7b%7bfilterName%7d%7d

<input type = "text" ng-model="filterName"/>
<h2>{{filterName}}</h2>
<a class="btn btn-default" href=
    <c:url value="students.html">
         <c:param name="fname" value="{{filterName}}"/>
    </c:url>
>Filter</a>

edit: I need to keep the c:url because i want to put some of the current params in the new url

<input type = "text" ng-model="filterName"/>
<h2>{{filterName}}</h2>
<a class="btn btn-default" href=
    <c:url value="students.html">
         <c:param name="fname" value="{{filterName}}"/>
         <c:param name="pageNumber" value="1"/>
         <c:forEach items="${param}" var="entry">
            <c:if test="${entry.key == 'itemsOnPage'}">
                <c:param name="${entry.key}" value="${entry.value}" />
            </c:if>
        </c:forEach>
>Filter</a>
Ad

Answer

This problem is unrelated to the value being enclosed in double quotes, but due to an incorrect understanding of the difference between client and server side.

In essence, your AngularJS filterName value only exists on the client, but you're trying to render it on the server using JSP (or a similar server-side technology).

The main question is: why do you need to use a server-side construct to render the URL? Why not just do it using Angular, e.g. with ngHref?

<a class="btn btn-default" ng-target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="students.html?fname={{filterName}}"/>
Ad
source: stackoverflow.com
Ad