Angular.js with PHP RESTful JSON API

This previous days I’ve been working with Angular.js “JavaScript MVC Framework create by Google” to enhance HTML with new attributes, expression, etc…

Below are the steps I made to access RestAPI with angular.

1. Declaring element of HTML as a root  using “ng-app” directive.

angular - directives

2. Including angular library.

angular - include angular

3. Calling our API using our controller.

angular - controller

4. Bind our data to HTML.

angular - bindings
5. Our post.php API.

angular - post

6. API Result.

angular - api Result
7. Result.

angular - result

Below is the full source:

<!DOCTYPE html>
<html ng-app>
<script src=”http://localhost:8081/webapi/cnd/js/angular.js”></script&gt;
<script type=”text/javascript”>
function simplebindcontroller($scope,$http){
success(function(data) {
$scope.user = data;

<div ng-controller=”simplebindcontroller”>
<li ng-repeat=”name in user”>
{{}} | {{}}


One thought on “Angular.js with PHP RESTful JSON API

  1. great! thanks for this. I might be able to use this on one of my projects. 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s