Why does angularJS need to start the server?

I am new to AngluarJs and when I tried to use it (using Webstorm) I noticed that the url I needed is localhost:62345

.

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

+3


source to share


2 answers


This is not angular but specific. angular runs on the frontend and hence there is no need to start the server to debug angular on the front end unless it is linked to the server. Also you can try running from file explorer and not have a problem.



+3


source


Angular Js does not 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 doesn't need a 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>
      

Run codeHide result


+1


source







All Articles