gpt4 book ai didi

angularjs - 如何在不使用 npm start 的情况下在生产中部署 angularjs 项目

转载 作者:太空宇宙 更新时间:2023-11-04 02:25:57 25 4
gpt4 key购买 nike

我正在使用 angularjs 开发一个网站,并使用 npm 托管本地开发服务器。

我将我的项目目录复制到公共(public) AFS目录并可以正常访问 index.html 页面,但 npm 依赖项不起作用。 (我遇到了相同的错误,就像我在本地打开我的 index.html 文件而不运行“npm start”一样)具体来说,错误发生在我创建的自定义验证中。

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

这里说 ngModel 没有 $validators 属性,因此我将“validInput”值分配给 undefined,这会导致错误。

如果我无法在生产目录上调用 npm start,如何在这个新的分布式文件系统中运行我的项目?

我必须在 app.js 中创建不同的环境吗?不太确定这意味着什么......

最佳答案

虽然已经晚了,你可以使用 ngc ,参见这里的例子 https://medium.com/@feloy/building-a-static-website-with-angular-universal-a1acc49e26e5

顺便说一句,Angular 通常被认为是单页响应式网页。

关于angularjs - 如何在不使用 npm start 的情况下在生产中部署 angularjs 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30473665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com