这是 home.controller.js
...
(function activate() {
...
loadCategories();
...
})();
...
// ...............................
function loadCategories() {
debugger;
homeService.getFeaturedCategories()
.then(function(categories) {
vm.categories = categories;
});
}
该函数调用homeService.getFeaturedCategories()。所以....
home.service.js
function getFeaturedCategories() {
return dataService.getFeaturedCategories();
}
对dataService.getFeaturedCategories()的函数调用 这是当 data.service.js 调用remoteDataService.js时,这个文件生成hhtp.get(我粘贴了data.service.js的完整代码):
(function() {
'use strict';
angular
.module('restaurant.common')
.factory('dataService', dataService);
dataService.$inject = ['ENV', '$injector'];
/* @ngInject */
function dataService(ENV, $injector) {
switch(ENV.dataProvider) {
case 'LOCAL':
return $injector.get('localDataService');
case 'REMOTE':
return $injector.get('remoteDataService');
case 'FIREBASE':
return $injector.get('firebaseDataService');
}
throw new Error('Data provider is not valid');
}
})();
我想知道:
谢谢!
答案 0 :(得分:0)
在你的Home.service中你应该有以下几行:
<?php
require_once "dbreg.php";
//if(isset($_GET['id']) == 'success') do this to get the id of all the users
if(isset($_GET['msg']) == 'success'){
echo "Data has been successfully updated";
}
$sqlquery = "SELECT username, passkey, email, firstname, lastname, gender, address, country, hobbies FROM regform WHERE id = '".$_GET['uid']."'";
$resultquery = mysql_query($sqlquery);
$row = mysql_fetch_assoc($resultquery);
if(!empty($_POST)){
$fname = $_POST['firstname'];
$lasttname = $_POST['lasttname'];
$usergender = $_POST['usergender'];
$address = $_POST['address'];
$country = $_POST['country'];
$updateQuery = "UPDATE regform SET firstname='".$fname."', lastname='".$lasttname."', gender='".$usergender."', address='".$address."', country='".$country."' WHERE id='".$_GET['uid']."'";
if(mysql_query($updateQuery)){
//echo "Data has been successfully updated";
header("Location: http://localhost/classwork2/adminedit.php?msg='success'");
}
else{
echo "Data has not updated";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Details</title>
</head>
<body>
<table border="1">
<form name="edit" id="edit" method="post" action="adminedit.php" enctype="multipart/form-data">
<tr>
<td>
<label>Firstname</label>
</td>
<td>
<input type="text" name="firstname" id="firstname" value="<?php echo $row['firstname'];?>">
</td>
</tr>
<tr>
<td>
<label>Lastname</label>
</td>
<td>
<input type="text" name="lasttname" id="lastname" value="<?php echo $row['lastname'];?>">
</td>
<tr>
<td>
<label>Gender</label>
</td>
<td>
<input type="radio" name="usergender" value="male" <?php if($row['gender'] == 'male'){?> checked<?php }?>>Male</input>
<input type="radio" name="usergender" value="female" <?php if($row['gender'] == 'female'){?> checked<?php }?>>Female</input>
<input type="radio" name="usergender" value="other" <?php if($row['gender'] == 'other'){?> checked<?php }?>>Other</input>
</td>
</tr>
<tr>
<td>
<label>Address</label>
</td>
<td>
<textarea name="address"><?php echo $row['address'];?></textarea>
</td>
</tr>
<tr>
<td>
<label>Country</label>
</td>
<td>
<select name="country">
<option value="Abc" <?php if($row['country'] == 'Abc' ){?> selected<?php }?>>India</option>
<option value="Bcd" <?php if($row['country'] == 'Bcd' ){?> selected<?php }?>>Brazil</option>
<option value="Cde" <?php if($row['country'] == 'Cde' ){?> selected<?php }?>>Japan</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Edit">
</td></tr>
</form>
</body>
</html>
将其更改为:( $ inject和参数的顺序应相同。)
homeService.$inject = ['dataService'];
function homeService(dataService){
...
}
并在你的fn中使用localDataService。