0

I have a input file which i can see in my jsp file and it renders the json object. I want to call this inside my JS file in the Angular controller.

The input file in JSP is.

 <input type="hidden" value=${getGlobalFeaturesList}
        ng-model="featureslistJson" id="getglobalfeaturelist">

In the controller i am calling

$scope.myData = ($scope.featureslistJson.ReadFeaturesResponse.feature);

Before this i was using external JSON FILE WHICH WORKS FINE

This call works fine

$http.get("script/data.json").success(function (response) {
      $scope.myData = (response.ReadFeaturesResponse.feature);
 });

How I do the same with the featureslistJson

I get error cant read ReadFeaturesResponse.

Any help will be good.

georgeawg
  • 48,608
  • 13
  • 72
  • 95
Insane Fragger
  • 63
  • 1
  • 12

1 Answers1

0

Use the ng-init directive:

<div ng-init="myData = ${getGlobalFeaturesList}">
</div>
app.controller("ctrl",function($scope) {
  $scope.$watch("myData", function(newValue) {
    console.log(newValue);
  })
})
georgeawg
  • 48,608
  • 13
  • 72
  • 95