javascript - 如何让 Angular 2 CLI ng 通过子目录提供服务

标签 javascript angularjs

我已经设置了 angular-cli.json 第 9 行“outDir”:“dist/bice/”并且构建很好,但我需要开发环境来反射(reflect) bice 子目录。例如。 http://localhost:4200/bice/

统计数据:

Linux (arch/antergos)

angular-cli: 1.0.0-beta.24
node: 7.5.0
os: linux x64
@angular/common: 2.4.0
@angular/compiler: 2.4.0
@angular/core: 2.4.0
@angular/forms: 2.4.0
@angular/http: 2.4.0
@angular/platform-browser: 2.4.0
@angular/platform-browser-dynamic: 2.4.0
@angular/router: 3.4.0
@angular/compiler-cli: 2.4.0

最佳答案

所以我通过导入环境并检查是否生产来解决这个问题。

接下来是如何在应用程序中提高它,以便我可以在任何地方设置它并让它反射(reflect)在所有组件上。我在 app.component 级别思考。

import { Component, OnInit } from '@angular/core';
import { environment } from '../../environments/environment';

if (environment.production) {
var urlProduction = null;
urlProdcution = '/bice';
}

@Component({
selector: 'app-presentation',
templateUrl: './presentation.component.html',
styleUrls: ['./presentation.component.sass']
})
export class PresentationComponent implements OnInit {
moduleTitle1 = 'Presentation Module';
moduleDescription1 = 'This will be the short description of the module and what sort of training it provides. From here the user can click the button and the pop-up modal will show up. An idea is to place a check mark on ones that users have completed...';
moduleButton1 = 'START MODULE';
url = urlProduction; // {{url}} in the template.

constructor() { }

ngOnInit() {

}
}

关于javascript - 如何让 Angular 2 CLI ng 通过子目录提供服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42146083/

相关文章:

css - Angular Material 中列布局中元素的响应大小

angularjs - 如何使用 ng-messages 显示 Checkbox set 和 Radio set 的错误消息?

javascript - Angular::屏蔽输入文本以在焦点上打开下拉列表

javascript - Angularfire2,startAfter()不适用于分页

javascript - Jquery变量错误

javascript - 文本偏移 Canvas 并影响鼠标悬停位置

javascript - 根据列值更改表格行的颜色

javascript - 使用 Protractor 测试时如何找到 ng-repeater 的最后一个元素

javascript - 使用括号表示法访问嵌套属性

javascript - 如何在循环运行函数的 SQL Server 中插入对象? ConnectionError : . 无法在处于 `Connecting` 状态的连接上调用 connect