===========================================================================
Update 1 Fixed code produce new error of
ReferenceError: inputName is not defined
on the line of
inputName:inputName,
Below is the new code
<script src="/library/angularjs/1.2.0-rc.3/angularjs.js"></script>
<script src="/library/angularjs/1.2.0-rc.3/angular-route.js"></script>
<script src="/library/angularjs/1.2.0-rc.3/angular-resource.js"></script>
<script>
var app= angular.module('myApp', ['ngRoute', 'ngResource']);
app.factory('Greeter', ['$resource',function($resource){
return $resource(
'http://123.com/processor.php',
{
inputName:inputName,
callback: 'JSON_CALLBACK'
},
{
query: {method:'GET',isArray:true}
});
}]);
app
.controller('MyCtrl', ['$scope', 'Greeter',
function($scope,Greeter){
/*alert("yes");*/
$scope.greet = function(){
//alert("greetttt");
alert("before greeeter"+$scope.inputName);
Greeter.query(
{inputName:$scope.inputName},
function(response){
alert(response[0].myCodeId);
$scope.output=response[0].myCodeId;
}
);
};
}]);
</script>
<div ng-app="myApp">
<div ng-controller="MyCtrl">
Your name:
<input type="text" ng-model="inputName" name="myInput" value="World"/>
<button ng-click="greet()">greet</button>
<div>
Test Output Here
{{output}}
</div>
</div>
</div>
I wonder where do I get it wrong?
Thanks