Benyamin Noori
Benyamin Noori

Reputation: 880

Why does angularJS need to run a server?

I'm new to AngluarJs, and when I was trying it out (using Webstorm) I noticed that the url it takes me to is localhost:62345.

Why does a JavaScript library require a server? What is the purpose of the webserver?

Upvotes: 4

Views: 4387

Answers (2)

Prashant K
Prashant K

Reputation: 909

Angular Js doesn't require a server until you want to use angular directives like 'ng-include', or you want page routing or ajax request in your application.

This basic snippet in angular needs no server.

(function() {
  'use strict';

  angular.module('myapp', [])
    .controller('AppController', AppCtrl)

  AppCtrl.$inject = ['$scope'];

  function AppCtrl($scope) {
    var vm = this;
    vm.companyName = "AlertEnterprise";
    vm.rows = ["Rajesh", "Prashant"];
  }
})();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>

<body ng-app="myapp" ng-controller="AppController as appVM">

  <p>{{appVM.companyName}}</p>
  <p ng-repeat="row in appVM.rows">
    <span>{{row}}</span>
  </p>
</body>

Upvotes: 2

binariedMe
binariedMe

Reputation: 4329

This is not angular but ide specific. Angular runs on frontend and hence there is no need to run a server to debug angular on front end as long as it doesn't involve server communication. Also you can try running from file explorer and have no issue.

Upvotes: 3

Related Questions