如何使用 angularjs 和 xampp 但不使用 node.js 进行服务器通信?
How can I use angularjs with xampp but without node.js for server communication?
我正在使用基本的 xampp 来编写 Web 应用程序
到现在为止,我已经使用 php 了。
但现在我已经切换到angularjs
没有nodejs
,我在任何地方都看不到服务器通信教程
因为我现在不太习惯使用 nodejs,所以我想直接将 angularjs 用于 Web 应用程序;比如获取数据并将数据添加到数据库中。
<body id="index" ng-app="notesApp" >
<h1>Hello servers!</h1>
<div ng-controller="maincntrl as cntrl" ng-repeat="todo in cntrl.items" class="item">
<div><span ng-bind="todo.label"></span></div>
<div>- <span ng-bind="todo.author"></span></div>
</div>
<script>
angular.module('notesApp',[])
.controller('mainCntrl',['$http', function($http){
var self= this;
self.items = [];
$http.get('/api/note').then(function(response){},function(errResponse){
console.error("error while fetching note");
});
}]);
</script>
</body>
此代码无效
关键是,Angular JS 是一个客户端框架。在服务器端使用什么并不重要。
这里是服务器与 PHP 通信的例子。
我正在使用基本的 xampp 来编写 Web 应用程序 到现在为止,我已经使用 php 了。
但现在我已经切换到angularjs
没有nodejs
,我在任何地方都看不到服务器通信教程因为我现在不太习惯使用 nodejs,所以我想直接将 angularjs 用于 Web 应用程序;比如获取数据并将数据添加到数据库中。
<body id="index" ng-app="notesApp" >
<h1>Hello servers!</h1>
<div ng-controller="maincntrl as cntrl" ng-repeat="todo in cntrl.items" class="item">
<div><span ng-bind="todo.label"></span></div>
<div>- <span ng-bind="todo.author"></span></div>
</div>
<script>
angular.module('notesApp',[])
.controller('mainCntrl',['$http', function($http){
var self= this;
self.items = [];
$http.get('/api/note').then(function(response){},function(errResponse){
console.error("error while fetching note");
});
}]);
</script>
</body>
此代码无效
关键是,Angular JS 是一个客户端框架。在服务器端使用什么并不重要。
这里是服务器与 PHP 通信的例子。