简体   繁体   中英

possibility to change a parameter php? from the controller

Is there a possibility to change a parameter params: {source:$scope.chartr1} from the controller - I would like to call a php file with variable parameters.

app.controller('Ctrl', function ($scope, $http) {
$scope.chartr1 = "2010-01-01";
var request = $http.get('xxx.php', {
    params: {source:$scope.chartr1}
 }).success(function(gl){
    $scope.users = gl;    
$scope.chartData = [['Gl', $scope.users]
];
 });

The problem is you are calling $http with the default parameter as soon as the controller runs. You should write the $http part in a function and call it only when the user is ready (ie after changing the input).

$scope.request = function() {
  $http.get('xxx.php', {params: source:$scope.chartr1})...
}

<input ng-model="chartr1">
<button type="button" ng-click="request()">submit</button> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM