java - Spring dont see angular -
i trying adapt app use angular, seems spring cannot see/communicate angular. here have :
controller.java:
@controller public class indexcontroller { @requestmapping(value = "/login", method = requestmethod.get, produces = {"application/json"}) public @responsebody map<string, object> getindexpage() { map<string, object> model = new hashmap<string, object>(); model.put("id", uuid.randomuuid().tostring()); model.put("content", "hello worl123321"); return model; } }
index.html:
<!doctype html> <html> <head> <title>title</title> <!--<link href="css/angular-bootstrap.css" rel="stylesheet"> <link rel="stylesheet" href="css/app.css"/>--> <style type="text/css"> [ng\:cloak], [ng-cloak], .ng-cloak { display: none !important; } </style> <script src="js/angular-bootstrap.js" type="text/javascript"></script>> <script src="app/app.js"></script> <script src="app/listview/listview.js"></script> </head> <body ng-app="myapp"> <!-- application content --> <div ng-include="'app/app.html'"></div> </body> </html>
app.html:
<div class="container"> <div ng-controller="appctrl" ng-cloak class="ng-cloak"> {{greeting.content}} </div> </div>
app.js:
angular.module('myapp', []) .controller('appctrl', function($scope, $http) { $http.get('/login/').success(function(data) { $scope.greeting = data; }); });
i output :
{"id":"01cdab29-e0ce-45ee-abb9-64b2640859ca","content":"hello worl123321"}
and there seems no angular scripts has been loaded...
what use serialise json ?
this maybe because of map<> have field 'content' between object , data try.
$scope.greeting = data.content;
i've heard of problem jackson adding "content" though hibernate problem.
if don't want field : create wrapper class having id , content field , use it.
Comments
Post a Comment