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>
In my controller:
$scope.profile_data_init = function() { $scope.prod_id="hi"; } //its working fine
but i can't init value get from server side using controller..code below
$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..!");
});
}
Try your request in 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>
and set $scope.form.product_id = $scope.prod_id = data[0].pid;
on success
$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..!");
});
}
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.