我想在linux机箱上运行角形,而不需要节点或快递。我已经创建了一个网站,但不确定什么是技术,哈哈。我假设我有一个使用express服务器的简单web服务器,请参阅下面的代码。
var express = require ('express');
var app = express();
var path = require('path');
app.use(express.static(__dirname + '/'));
app.listen(8080);
console.log('Magic happens on port 8080');我使用节点服务器命令启动它。剩下的代码是角用户界面。
我是否需要使用express (并将其托管在与节点兼容的服务器上),还是只需在没有express的linux盒上运行?如果是这样的话,我是否需要用其他的东西替换我的server.js文件(上面)?或者..。目前,它不在linux机器上工作,但在本地工作得很好。
**编辑:我在我的共享服务器上测试了一个有角度的'hello world‘应用程序,它运行得很好。当我在共享服务器上运行完整的角应用程序时,我会得到以下错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module routerApp due to:
Error: [$injector:nomod] Module 'routerApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.**编辑:在回答@RobertMoskal下面的问题时,在共享服务器上工作的角hello world测试基本上如下:
<input ng-model="name" type="text" placeholder="Type a name here">
<h1>Hello {{ name }}</h1>而真正的应用程序基本上是这样的,在html中使用ui视图和ng-重复:
var routerApp = angular.module('routerApp', ['ui.router']);
routerApp.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/home');
$locationProvider.html5Mode(false).hashPrefix("");
$stateProvider
// HOME STATES AND NESTED VIEWS ========================================
.state('home', {
url: '/home',
templateUrl: 'partial-home.html',
// onEnter: scrollContent
})
// ANIMATION AND NESTED VIEWS ========================================
.state('animation', {
url: '/animation',
templateUrl: 'partial-anim.html',
controller: function($scope) {
$scope.animations = [
{ title:'One', url:'http://yahoo.com', bg:'#f8f8f8', width:'160', height:'600', imageAsset:'assets/imgs/web/MyWebsites_1.jpg', paragraph:'some text of some description'},
{ title:'Two', url:'http://google.com', bg:'#f8f8f8', width:'160', height:'600', imageAsset:'assets/imgs/web/MyWebsites_2.jpg', paragraph:'rabbit rabbit rabbit'},
{ title:'Three', url:'http://bambam.com', bg:'#f8f8f8', width:'160', height:'600', imageAsset:'assets/imgs/web/MyWebsites_3.jpg', paragraph:'blahiblahblah'}];
}
})
// GAME VIEWS ========================================
.state('game', {
url: '/game',
templateUrl: 'partial-game.html'
})
// CONTACT VIEWS ========================================
.state('contact', {
url: '/contact',
templateUrl: 'partial-contact.html'
})
});发布于 2015-06-22 21:32:28
您需要一些web服务器作为“静态”资产来服务器您的角应用程序。这可以是apache或nginx或任意数量的web服务器。大多数linux发行版都可以轻松地安装它们。
您还可以使用内置的python web服务器进行超级轻量级操作:
cd /var/www/
$ python -m SimpleHTTPServer您甚至可以在github上免费托管您的应用程序。
在所有情况下,您只需确保web服务器正在从正确的路径为您的资产提供服务。上面的python示例示例可能在/var/www/index.html中有您的应用程序入口点,它将被用作http://localhost:8000/index.html。
https://stackoverflow.com/questions/30990136
复制相似问题