0
我是AngularJS的新手。我正在学习将变量的值传递给angularJS。 但由于某些未知的原因,我无法做到。如何使用AngularJS保留JSP的变量值
下面是.jsp页面我认为这是正确的:
<body >
<div ng-controller="customersController">
<label>Value</label>
<input type="text" ng-model=something></input>
<button ng-click="punchIt()">click me!</button>
<br>Obtained value : {{ value }}
</div>
</body>
在各自的.js页面上,从.jsp文件传递价值没有得到retained.The第一个警报函数返回假设:东西的价值,但它是假设返回:undefined。 下面是.js文件:
var myApp = angular.module("getInfo", []);
myApp.controller("customersController", function($scope, $http){
$scope.punchIt = function ($scope, $http) {
var data = {Value: $scope.something};
alert("assumed : "+ $scope.something);
$http.post("http://localhost:8082/HelloWorldWS/services/HelloWorldImpl",data)
.success(function (data, status, header) {
alert("in success " + data);
$scope.value = data;
}).error(function (data) {
alert("in error method " + status);
$scope.value = "error "+ data;
});
};
});
请出提出一些办法。 谢谢。
'NG-模型= something'显然不会插入一个JSP变量。是不是有写JSP到视图语法? – tymeJV 2014-10-09 15:56:56