-2

I was learning angular2, Now I have one doubt. How to use PHP in Angular 2? Because Angular 2 files are .html type. So how to use it?

0

2 Answers 2

-1

The HTML files would call PHP API(.php files), to get response and display accordingly.

For example:

<script>
  var countryApp = angular.module('countryApp', []);
  countryApp.controller('CountryCtrl', function ($scope, $http){
    $http.get('country.php').success(function(data) {
      $scope.countries = data;
    });
  });
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

Not necessary + it's angularJs
-1

You should think differently, what should I use as front end & back end ? Angular works with webservices and API. So in most cases, you'll need to build an API. I would suggest you ExpressJS & Node or even an ElasticSearch Database to first understand APIs.

Useful link : https://www.codeofaninja.com/2017/02/create-simple-rest-api-in-php.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.