AngularJS : ไม่สามารถเอาข้อมูลที่ดึงมาจาก ฐานข้อมูล มาโชว์ยัง Textbox ใน ng-model= ได้ครับ

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา AngularJS : ไม่สามารถเอาข้อมูลที่ดึงมาจาก ฐานข้อมูล มาโชว์ยัง Textbox ใน ng-model= ได้ครับ

AngularJS : ไม่สามารถเอาข้อมูลที่ดึงมาจาก ฐานข้อมูล มาโชว์ยัง Textbox ใน ng-model= ได้ครับ


Meijicpipo 171.4.248.xxx 15-07-2015 01:12:35

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
ขอโทษครับ คือ รูปไม่ขึ้นครับ


meijicpipo 171.4.248.xxx 15-07-2015 01:17
 ความคิดเห็นที่ 2
script.js คือตัว Controller ที่มี Funtion $scope.openEdit เอาไว้สำหรับ เปิด popup modal ของ ui.bootstrap ครับ



meijicpipo 171.4.248.xxx 15-07-2015 01:21
 ความคิดเห็นที่ 3
script.js คือตัว Controller ที่มี Funtion $scope.openEdit เอาไว้สำหรับ เปิด popup modal ของ ui.bootstrap ครับ

http://www.mx7.com/view2/ythtNEeMvuBJCHzt = ลิ้งรูป
$scope.openEdit = function (p,size) {

	    var modalInstance = $modal.open({
	      animation: $scope.animationsEnabled,
	      templateUrl: 'customerEdit.html',
	      controller: 'ModalInstanceCtrl',
	      size: size,
	      resolve: {
	        items: function () {
	          return p;
	        }
	      }
	    });
	   	alert("Step1");
	    $scope.update_prod = true;
		$scope.add_prod = false;
		$scope.dataS = {};
		$http.post('selectEdit.php',
		{
			'prod_index' : p
		}
			)
		.success(function (data){
			$scope.dataS.CustomerID			=	data[0]["CustomerID"];
			$scope.dataS.Name				=	data[0]["Name"];
			$scope.dataS.Email				=	data[0]["Email"];
			$scope.dataS.CountryCode		=	data[0]["CountryCode"];
			$scope.dataS.budget				=	data[0]["Budget"];
			$scope.dataS.Used				=	data[0]["Used"];

		})
		.error(function (data){

		})


meijicpipo 171.4.248.xxx 15-07-2015 01:23
 ความคิดเห็นที่ 4
selectEdit.php เป็นตัว Connect Database

http://www.mx7.com/view2/ythwjYRxyG39rkgN = ลิ้งรูป

header("Access-Control-Allow-Origin: *");
	header("Content-Type: application/json; charset=UTF-8");

	include'config.php';

	$data = json_decode(file_get_contents("php://input"));
	$index = mysql_real_escape_string($data->prod_index);
	$qry = mysql_query('SELECT * FROM customer WHERE CustomerID = "'.$index.'" ');
	$data = array();

	if($qry === FALSE) { 
    die(mysql_error()); // TODO: better error handling
	}

	while ($row = mysql_fetch_array($qry)) {
		# code...
		$data[] = array(
			"CustomerID"	=> $row['CustomerID'],
			"Name"			=> $row['Name'],
			"Email"			=> $row['Email'],
			"CountryCode"	=> $row['CountryCode'],
			"Budget"		=> $row['Budget'],
			"Used"			=> $row['Used']
			);
	}

	print_r(json_encode($data));
	return json_encode($data);


meijicpipo 171.4.248.xxx 15-07-2015 01:26
 ความคิดเห็นที่ 5
customerEdit.html คือตัวที่ต้องการ นำข้อมูลมาแสดง ยัง Textbox ใน attribute ที่ชื่อ model ครับ ปรากฏว่าไม่สามารถนำข้อมูลที่ดึงจาก ฐานข้อมูล มาแสดงได้ครับ

http://www.mx7.com/view2/ythy9q3MiAHVa6Cn = ลิ้งรูป





meijicpipo 171.4.248.xxx 15-07-2015 01:30
 ความคิดเห็นที่ 6
ลิ้งรูป = http://www.mx7.com/i/d6d/cSF3Ku.png
ผลการ ทดลอง run โปรแกรม ครับ

ปล. ช่วยด้วยครับ .... ขอบคุณมากครับ


meijicpipo 171.4.248.xxx 15-07-2015 01:31
 ความคิดเห็นที่ 7
อาจจะเป็นในส่วนของการกำหนด ค่าเข้าไปใน controller หรือเปล่า
ลองดูเนื้อหานี้เป็นแนวทาง

angularjs การแสดงข้อมูล และแก้ไขข้อมูล กับฐานข้อมูล mysql ตอนที่ 12 


ninenik 180.183.13.xxx 15-07-2015
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ