的index.html:
<form name="cca">
<input type="text" ng-model="form.product_id" ng-init="form.product_id=prod_id">
<input type="button" ng-click="profile_updated()">
</form>
在我的控制器中:
$scope.profile_data_init = function() { $scope.prod_id="hi"; } //its working fine
但我无法使用controller..code
从服务器端获取init值 $scope.profile_data_init = function() {
//alert('uu');
//console.log($scope.loginform);
$http.post("ajax/profile_updation.php",{profile_up_init:"profile_init"}).
success(function(data, status, headers, config) {
$scope.prod_id=data[0].pid; //json data
}).error(function(data, status, headers, config) {
alert("Please Try Again..!");
});
}
答案 0 :(得分:0)
在ng-init
<form name="cca">
<input type="text" ng-model="form.product_id" ng-init="profile_data_init()">
<input type="button" ng-click="profile_updated()">
</form>
并在成功时设置$scope.form.product_id = $scope.prod_id = data[0].pid;
$scope.profile_data_init = function() {
$http.post("ajax/profile_updation.php",{profile_up_init:"profile_init"}).
success(function(data, status, headers, config) {
$scope.form.product_id = $scope.prod_id = data[0].pid; //json data
}).
error(function(data, status, headers, config) {
alert("Please Try Again..!");
});
}