Hallo Ich lerne Winkel und ich weiß nicht, wie man PHP-Variable an Winkel-Controller übergeben und dann durch HTML-Select anzuzeigen. Ich denke, ich sollte dies durch eckige http "Post" -Methode tun, aber es funktioniert nicht. Irgendeine Idee? Bitte helfenPHP Variable zu Winkel
Html-Code:
<div id="find" ng-controller="SelectController">
<ol class="nya-bs-select" ng-model="model" disabled="disable">
<li nya-bs-option="option in options">
<a>{{option.name}}</a>
</li>
</ol>
<div>{{model.text}}</div>
</div>
Php Code:
<?php
$text1 = get_field('contact1');
$text2 = get_field('contact2');
$text3 = get_field('contact3');
?>
Angular Code:
app.controller('SelectController', ['$scope', function($scope, $http) {
var request = $http({
url: "../page-contact.php",
method: "POST",
data: {
data1: $text1,
data2: $text2,
data3: $text3
}
}).success(function(response) {
console.log(response);
});
$scope.options = [
{text: data1, name: 'Option A'},
{text: data12, name: 'Option B'},
{text: data3, name: 'Option C'}
];
}]);
Es tut mir leid, aber ich weiß nicht, was mit diesem weiter zu tun – Kermit
Sie haben PHP-Variable in eckigen $ Bereich jetzt. Was willst du noch ? Sie können die PHP-Variable im Controller von angular übergeben. –
Es funktioniert nicht. Console.log ($ scope.var) zeigt "=$text1; ?>" – Kermit