how to get model attribute value in angularjs from spring controller

前端 未结 4 604
陌清茗
陌清茗 2020-12-21 03:28

I have spring controller defined as

@Controller
public class TestController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Request         


        
相关标签:
4条回答
  • 2020-12-21 03:56

    I've faced with the same issue, but ($location.search()).attributeKey doesn't work for me. In my angularJs controller I'm receiving 'undefined' value via ($location.search()).attributeKey.

    0 讨论(0)
  • 2020-12-21 04:16

    I had this problem for some time . I used a 'hackish' way to access a variable added as a modal attribute in the backend .

    let say you have added "some-data" to the model like follows.

    model.addAttribute("some-data-id", "some-data");
    

    in the jsp where the ctrl is initializing add the attribute to a hidden html element such as a span

    <span style="display:none" id="someDataId">${some-data-id}</span>
    

    and in the controller , retrieve the value using angular.element('#some-data-id').innerHTML

    0 讨论(0)
  • 2020-12-21 04:17

    Try this:

    ($location.search()).Authorization

    More details about $location and parameters: https://docs.angularjs.org/api/ng/service/$location

    0 讨论(0)
  • 2020-12-21 04:20

    try ng-init="var = ${Authorization}" then in controller $scope.var

    0 讨论(0)
提交回复
热议问题