Php templateUrl:“../assets/js/libs/angular/views/add_player.html'})。当(“/clubs',{controller:'clubsCtrl',templateUrl:”../assets/js/lib
Php templateUrl:“../assets/js/libs/angular/views/add_player.html'})。当(“/clubs',{controller:'clubsCtrl',templateUrl:”../assets/js/lib,php,angularjs,forms,select,post,Php,Angularjs,Forms,Select,Post,templateUrl:“../assets/js/libs/angular/views/add_player.html'})。当(“/clubs',{controller:'clubsCtrl',templateUrl:”../assets/js/libs/angular/views/clubs.html')否则({重定向到:'/players'})我应该创建一个新的控制器吗?我已经编辑了答案。增加的步骤应该是所有你需要让它工作。。。有希望地。。。好luckI确实需要更多的帮助,但请不要着急,
templateUrl:“../assets/js/libs/angular/views/add_player.html'})。当(“/clubs',{controller:'clubsCtrl',templateUrl:”../assets/js/libs/angular/views/clubs.html')否则({重定向到:'/players'})代码>我应该创建一个新的控制器吗?我已经编辑了答案。增加的步骤应该是所有你需要让它工作。。。有希望地。。。好luckI确实需要更多的帮助,但请不要着急,只要你觉得时间合适。同时,我会用谷歌搜索你的虚拟机建议,看看我是否能找到答案:Thanx为你提供帮助你键入fastewr然后我是我的朋友。我们同时在写评论。我现在试试你的建议。Thanx againNo担心,我把所有对社交生活的渴望都换成了StackOverflow points;)
<div class="form-group" ng-controller="clubsCtrl">
<select class="form-control" style="margin-top:10px;"
ng-options="club.ID as club.SHORT_NAME for club in clubs"
ng-model="selected_club_id">
</select>
<label>Odaberite klub kojem igrač pripada</label>
<p>TEST : ID za odabrani klub :{{selected_club_id}}</p>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control"
id="firstname"
ng-model="firstname">
<label for="firstname">Ime</label>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<input type="text" class="form-control"
id="lastname" ng-model="lastname">
<label for="lastname">Prezime</label>
</div>
</div>
</div>
$scope.addPlayer = function()
{
$http.post('add_player.php',
{
'selected_club_id' : $scope.selected_club_id,
'firstname' : $scope.firstname,
'lastname' : $scope.lastname,
'shirt_number' : $scope.shirt_number,
'position' : $scope.position,
'age' : $scope.age,
'national_team' : $scope.national_team,
'height' : $scope.height,
'weight' : $scope.weight,
'price' : $scope.price,
'ownership' : $scope.ownership,
'datum_rodjenja' : $scope.datum_rodjenja
}
).success(function(data, status, headers, config)
{
infoTime('<b>Success</b>');
});
};
<?php
// Including database connections
require_once '../assets/database/config.php';
$data = json_decode(file_get_contents("php://input"));
if (count($data) > 0)
{
// escape_string is just a helper function
$id_team = escape_string($data->selected_club_id);
$firstname = escape_string($data->firstname);
$lastname = escape_string($data->lastname);
$shirt_number = escape_string($data->shirt_number);
$position = escape_string($data->position);
$age = escape_string($data->age);
$national_team = escape_string($data->national_team);
$height = escape_string($data->height);
$weight = escape_string($data->weight);
$price = escape_string($data->price);
$ownership = escape_string($data->ownership);
$datum_rodjenja = escape_string($data->datum_rodjenja);
// query is justa helper function
$query = query("INSERT INTO players(firstname, lastname, id_team, shirt_number, position, age, national_team, height, weight, price, ownership, date_of_birth, id_status) VALUES('{$firstname}','{$lastname}','{$id_team}','{$shirt_number}','{$position}','{$age}','{$national_team}','{$height}','{$weight}','{$price}','{$ownership}','{$datum_rodjenja}', '1')");
$insert_result = confirm($query); // confirm = helper function
# JSON-encode the response
echo $json_response = json_encode($insert_result);
}