How to deploy angularjs project in production without using npm start

1.3k Views Asked by At

I am developing a website using angularjs and am using npm to host a local development server.

I copied my project directory into a public AFS directory and can access the index.html page fine but the npm dependencies arent working. (I am getting the same errors as if I would open my index.html file locally without running "npm start") Specifically, the error happens in a custom validation I created.

angular.module('myApp').directive('customValidator', function() {
  return {
    require: 'ngModel',
    link: function($scope, element, attrs, ngModel) {
      ngModel.$validators.validInput = function(value) {
        -------custom validation-----------
        return isValid;
      };
    }
  }
});

Here it says ngModel does not have a $validators property and therefore I am assigning a value of 'validInput' to undefined, which results in the error.

How can I run my project in this new distributed file system if I can't call npm start on the production directory??

Do I have to create different environments in my app.js? Not really sure what that even means...

1

There are 1 best solutions below

0
rajesk On

Its late though , You can use ngc , see example here https://medium.com/@feloy/building-a-static-website-with-angular-universal-a1acc49e26e5

BTW angular generally are ment to be single page responsive webpages.